JavaScript-də Günün Sonu

Gəlin cari günün sonunu ehtiva edən tarix obyektini əldə edək:

javascriptlet now  = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59);

Cari günün sonu kimi növbəti günün gecə yarısı (1 saniyə fərqlə) hesab edilə bilər:

javascriptlet now  = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0);

Artıq bildiyiniz kimi, bu halda sıfırları buraxmaq olar:

javascriptlet now  = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1);

Yeri gəlmişkən, gecə yarısı həm də cari günün 24:00:00 vaxtı olacaq:

javascriptlet now  = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 24, 0, 0);

Sıfırları buraxaq:

javascriptlet now  = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 24);
Задание 1

Günün sonuna qədər neçə saat qaldığını müəyyən edin.