Akhir Hari dalam JavaScript
Mari dapatkan objek tarikh yang mengandungi akhir hari semasa:
let now = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59);
Boleh juga dikira sebagai akhir hari semasa ialah tengah malam
hari berikutnya (perbezaan 1 saat):
let now = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0);
Seperti yang anda sudah tahu, nilai sifar dalam kes ini boleh ditinggalkan:
let now = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1);
Selain itu, tengah malam juga boleh diwakili oleh waktu
24:00:00 hari semasa:
let now = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 24, 0, 0);
Tinggalkan nilai sifar:
let now = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 24);
Tentukan berapa jam lagi yang tinggal hingga akhir hari.