ng2-datepicker icon indicating copy to clipboard operation
ng2-datepicker copied to clipboard

Datepicker timezone

Open theunreal opened this issue 8 years ago • 6 comments

How I can change the timezone of the datepicker? When I save the value to my database, I see 30 minutes difference between my current clock to the date. I'm using this format:

format="YYYY-MM-DD HH:MM:SS"

theunreal avatar Oct 15 '16 11:10 theunreal

Currently you can't, but locales are part of the roadmap.

Now that being said, timezone are a view matter. I wouldn't save time zoned date into a database but rather date at UTC time (string) or date in milliseconds (number).

ghetolay avatar Oct 15 '16 15:10 ghetolay

Thanks for your reply! But even if I willl use millseconds in this case that will be the wrong number, since there is 30 minutes difference. Glad to hear that timezone is part of the roadmap.

theunreal avatar Oct 15 '16 15:10 theunreal

I've been thinking about your issue and I don't think DatePicker is responsible of it. I had the new implementation in mind where we returns a momentjs object as date but with the current implementation the date is returned as a string (viewFormat) there is no time involved.

Also why are you using a format with time fields in it, why would you need hours, minutes and seconds to set a date ?

Can you explain a bit more about how your code works ?

ghetolay avatar Oct 16 '16 10:10 ghetolay

Here's an example where this would be useful: I'm storing a date of birth in a database as midnight UTC on that date. When I display that in the datepicker, it's showing the day before the actual birthday, because I'm in PST which is 7 hours earlier. It would be great if I could just tell the datepicker to display in UTC.

sjmerel avatar Apr 18 '18 20:04 sjmerel

@sjmerel was there ever a solution implemented for this? Or did you come up with a workaround?

speence avatar Mar 01 '19 18:03 speence

I worked around by converting the dates to the browser's timezone before passing them to the datepicker.

sjmerel avatar Mar 01 '19 19:03 sjmerel