MomentJS date string adds one day

Viewed 5204

I don't understand why this date is saved as +1 day:

startdate = "2017-11-29T23:59:59.999Z";
var new_date = moment(startdate).format('DD/MM/YYYY'); // --> gives 30/11/2017

But if I do:

startdate = "2017-11-29";
var new_date = moment(startdate).format('DD/MM/YYYY'); // --> gives the correct date 29/11/2017

Any ideas?

Here is a jsfiddle showing this: http://jsfiddle.net/jbgUt/416/

Thanks!

2 Answers

Late to the party on this one, but I did just convert a few of our product's date-time objects to https://moment.github.io/luxon/

Takes out the need for the .utc() method above.

Related