-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
  • 10,309
  • 16
  • 82
  • 148

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
  • 185,685
  • 31
  • 370
  • 359