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').??

Irony Stack
  • 2,700
  • 3
  • 24
  • 38
Nick
  • 399
  • 4
  • 12

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');
Irony Stack
  • 2,700
  • 3
  • 24
  • 38