I need to have the following functionality in moment js, for my app.
var nDay = moment(2007, 0, 28).next('date'); //--> 2007-0-29T00:00:00.00
var pDay = moment(2007, 0, 28).previous('date'); //--> 2007-0-27T00:00:00.00
Similarly:
.next('week'), .next('month')
and gets the particular date back.
I know momentjs has manipulation methods, but using them is a pain as it mutates the original. Even with the .clone()
, it's not easy.
So guys, how to implement this next()
, and previous()
methods, in moment or in js?
Or, what is the easiest way to find the day after a particular day?