5

Basically,

I received a date from my server which is, when printed out in the web console, this : Date 2016-05-04T09:00:00.000Z

Since, im using AngularJs, I did a binding using ng-model with an input time type.

Now the problem, is when ever I show the date in that input, I dont see: 9:00, but 5:00 (9:00 - 4:00) (I'm in a GMT -4 zone)

However the date isn't supposed to be a Universal Time, but as you can see it is parsed to local time. Any way to stop this?

1 Answer 1

5

The time zone to be used to read/write the Date instance in the model can be defined using ngModelOptions. By default, this is the timezone of the browser. AngularJS API input[time]

In your case the following option should do the trick.

<input type="time" ng-model-options="{ timezone: '-0400' }">

But beware with this option you are overwriting the browser's timezone. That means if a user operates in UTC+2 the input time is still treated as UTC-4.

Sign up to request clarification or add additional context in comments.

1 Comment

Cool & interesting +1, what will happen in case of internationalization?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.