# End of the day in JavaScript

Let's get a date object containing the end of the current day:

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

You can consider the end of the current day as midnight of the next (difference is `1` second):

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

As you already know, zeros can be omitted in this case:

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

By the way, midnight will also be the time `24`:00:00 of the current day:

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

Omit the zeros:

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

Determine how many hours are left before the end of the day.

←→
↑
en ru