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!
If a time part is included, an offset from UTC can also be included as +-HH:mm, +-HHmm, +-HH or Z.
Add utc()
to avoid it.
moment(startdate).utc().format('DD-MM-YYYY')
or
moment.utc(startdate).format('DD-MM-YYYY')
If you want to parse or display a moment in UTC, you can use moment.utc() instead of moment()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With