M
M
maratt2019-07-16 19:20:26
JavaScript
maratt, 2019-07-16 19:20:26

How to get the number of milliseconds until tomorrow?

How to get the number of milliseconds until tomorrow?
From now until 12 midnight, that is, until 00:00:00 the next day.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2019-07-17
@maratt

function getMSBeforeMidnight() {
  const today = new Date();
  const tomorrow = new Date(
    today.getFullYear(),
    today.getMonth(),
    today.getDate() + 1,
    0, 0, 0);
  return tomorrow.getTime() - today.getTime();
}

S
Shohruh Shaimardonov, 2019-07-16
@joeberetta

I think you have enough logical thinking. Find the right one for you.
Read

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question