Օրվա ավարտը JavaScript-ում
Եկեք ստանանք օբյեկտ ամսաթվով, որը պարունակում է ընթացիկ օրվա ավարտը.
let now = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59);
Ընթացիկ օրվա ավարտ կարելի է համարել հաջորդ օրվա կեսգիշերը
(տարբերությունը 1 վայրկյան է).
let now = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0);
Ինչպես արդեն գիտեք, զրոները այս դեպքում կարելի է բաց թողնել.
let now = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1);
Ի դեպ, կեսգիշեր կհամարվի նաև ընթացիկ օրվա
24:00:00 ժամանակը.
let now = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 24, 0, 0);
Բաց թողնենք զրոները.
let now = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 24);
Որոշեք, թե քանի ժամ է մնացել օրվա ավարտին։