-3

I have a Javascript application and I'm using MomentJS to deal with timestamps and dates. Because a requirement now I need to find out the unix timestamp (seconds since epoch) of the next Monday, given the current date. I couldn't find any solution online except for some code that does a lot of DIY date manipulation, converting back and forth between strings and timestamps, a complete mess

Do you know any neat way to get the unix timestamp of the next Monday in a reliable way? By Monday I mean the first second of it

Gianluca Ghettini
  • 11,129
  • 19
  • 93
  • 159

1 Answers1

1

Try this:

moment.utc().isoWeekday(8).startOf('day').unix()

Unix timestamp of the first day of the next month:

moment.utc().add(1, 'month').startOf('month').unix()
robertklep
  • 198,204
  • 35
  • 394
  • 381