How to get date in UTC?
Hi, currently the datepicker is using my browsers tz, but i want to have it ALWAYS to use utc regardless where the user sits in the world. How can i achieve this?
Use the timezone UTC.
For example, <div date-picker timezone="UTC"></div>
@DanTalash
Didn't work for me..
<div date-picker timezone="UTC"></div>
It appears to work for me on Chrome/Firefox/IE. Does this plunkr work for you?
Yeah it seems normal, but I tried something like the Live demo and it does not work .. do you have some tips, what i'm doing wrong?
Example:
<input date-time ng-model="dates.minDate" id="pickerMinSelector" date-change="changeMinMax" max-date="maxDate" view="date" timezone="UTC" format="lll" class="ng-pristine ng-valid ng-scope ng-valid-max ng-touched">
Thanks.
I still cannot reproduce any issue. Please see this updated plunkr. Does it appear normal to you?
I expected this format: DD/MM/YYYY HH:mm 22/02/2017 08:45, but is showing like this :2017-02-18T12:00:00.000Z.(Look the date.minDate format)
Example:
<input date-time ng-model="dates.minDate" date-change="changeMinMax" max-date="maxDate" view="date" timezone="UTC" format="DD/MM/YYYY HH:mm"> {{dates.minDate}}
You should look into the moment format functions. Because dates.minDate is a moment object, if you need to display it in a particular format then you will need to specify what the format is. If you just dump it to the page with the curly braces, angular calls toString() on the object, which is why you're seeing the unexpected date format.
Look at this updated plunkr for an illustration.
@DanTalash Thanks for the help, it solved my problem :+1: