I'm using datetimepicker.js and its date
function returns a moment.js object. It does so with the local UTC offset in it and my original date has a different offset.
My original date:
2015-10-01T15:00:00.000Z
What I display on the date time picker (DD-MM HH:mm
):
01-10 15:00
What I get:
2015-10-01T15:40:00+01:00
What I want:
2015-10-01T15:40:00+00:00
Note how I removed the +01 offset at the end.
How can I do this applying it for any local UTC ? This is, without having to manually remove the 01 (as it can be a any other local offset depending on the user location).
var momentDate = timePicker.data("DateTimePicker").date();
console.log(momentDate.format());
//this prints 2015-10-01T15:40:00+01:00
You need to explicitly specify the format.
Try this:
momentDate.format('YYYY-MM-DDTHH:mm:ss')
this will give the result as
2015-10-01T15:40:00