'Timezone Property of ngModelOptions of Angular-Ui Bootstrap Popup DatePicker
We are using the Angular-Ui Bootstrap Popup DatePicker in our application and have been running into issues such as this where the previous day gets selected to that which was actually selected by the user.
We set the date of the picker as UTC from the server (json). Although, Javascript Date objects are local, hence the mismatch.
As a solution (apparently) they added an ngModelOptions and I've seen it used like:
var date = new Date()
$scope.timezone = ((date.getTimezoneOffset() / 60) * -100)
with markup
<input type="date"
ng-model="dateModel"
ng-model-options="{timezone: timezone}" />
But the doco for that picker does not really explain how it uses/consumes that timezone property. The closest I could find for an explanation is the doco for the ngModelOptions itself where it says:
You can specify the timezone that date/time input directives expect by providing its name in the timezone property.
I'm hoping someone can give a brief explanation as to how that picker uses the timezone property of the ngModelOptions directive and whether I should set it to utc or the browser offset to utc.
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
