ng2-datepicker
ng2-datepicker copied to clipboard
Datepicker timezone
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"
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).
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.
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 ?
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 was there ever a solution implemented for this? Or did you come up with a workaround?
I worked around by converting the dates to the browser's timezone before passing them to the datepicker.