user984621
user984621

Reputation: 48453

date time format adds one more hour

I am loading from a database table a datetime column - and the value is 2015-03-04 21:00:00 UTC.

When I try to convert this format into datetime picker, like this:

date = moment($("#event_start").val()); // date time value from database
$("#event_start").val(date.format('YYYY-MM-DD HH:mm')); // formatting the date time
$("#event_start").datetimepicker(); // "run" it as datetimepicker

But instead of the desire output in the datetimepicker field 2015-03-04 21:00, there's 2015-03-04 22:00.

Why it adds one more hour? How to get rid of it and display the proper time?

Thank you in advance.

Upvotes: 0

Views: 1433

Answers (1)

technophobia
technophobia

Reputation: 2629

Have you tried .utc()?

$("#event_start").val(date.utc().format('YYYY-MM-DD HH:mm'));

Demo

Upvotes: 1

Related Questions