Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get date in UTC? #316

Open
iamstormnet opened this issue Dec 17, 2016 · 8 comments
Open

How to get date in UTC? #316

iamstormnet opened this issue Dec 17, 2016 · 8 comments

Comments

@iamstormnet
Copy link

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?

@DanTalash
Copy link
Contributor

Use the timezone UTC.

For example, <div date-picker timezone="UTC"></div>

@leonardors95
Copy link

@DanTalash
Didn't work for me..
<div date-picker timezone="UTC"></div>

@DanTalash
Copy link
Contributor

It appears to work for me on Chrome/Firefox/IE. Does this plunkr work for you?

@leonardors95
Copy link

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.

@DanTalash
Copy link
Contributor

DanTalash commented Feb 21, 2017

I still cannot reproduce any issue. Please see this updated plunkr. Does it appear normal to you?

@leonardors95
Copy link

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}}

@DanTalash
Copy link
Contributor

DanTalash commented Feb 22, 2017

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.

@leonardors95
Copy link

@DanTalash Thanks for the help, it solved my problem 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants