0

Using momentjs, I am trying to represent tomorrow at 7:00 AM (in server time).

Something like this:

var tomorrowEarlyAm = moment().add(1, 'day').add(7, 'hour');

However, of course, adding 1 day means we are at this same time tomorrow, so adding 7 hours is basically adding 31 hours.

The difficulty is that I don't know a simple way of clipping this to midnight:

var tomorrowMidnight = moment().add(1, 'day').??

Shankar
  • 2,890
  • 3
  • 25
  • 40
Nick
  • 466
  • 1
  • 6
  • 12
  • `moment().startOf('day').add(1, 'day').add(7, 'hour');` – Mat J Oct 15 '19 at 16:46
  • you may want to refer to this https://stackoverflow.com/questions/8636617/how-to-get-start-and-end-of-day-in-javascript/29328933 – Shankar Oct 15 '19 at 16:55

1 Answers1

1

basically you can go to today's 12 AM by using .startOf('day') and then add one day .add(1, 'day') and then 7 hours .add(7, 'hour') all to gather as bellow,

moment().startOf('day').add(1, 'day').add(7, 'hour');

as suggested by @Mat J

or you may add 31 hours directly

moment().startOf('day').add(31, 'hour');
Shankar
  • 2,890
  • 3
  • 25
  • 40