Closed rvdhooft closed 7 years ago
I have intentionally removed timezone because it's confusing a lot of users because the timezone is normally set by server-side, and client-side translation on the server-side generated string is very different from region to region.
https://github.com/ng2-ui/ng2-datetime-picker/blob/master/src/ng2-datetime.ts#L93
If we need to respect timezone, we can do it by simply not calling that function without having extra code.
Could you build a requirement for this, so that I can design it simpler?
Thanks for your response. My requirement is that the user is able to choose their default timezone and all dates will be in the selected timezone; for example, if I am in the US/Eastern timezone I can choose to have all dates be shown as US/Central, and I would like to display the chosen timezone in the input.
The removeTimezone
method referenced above is only called when moment is undefined.
I changed the component to use moment when it's available to build the selected date, because moment will preserve the timezone info passed in, whereas using just the Javascript Date methods will convert to local time. This is useful for any situation where a user needs to set the default timezone (using moment-timezone) to any timezone other than their local timezone. I added an example (ng-utils-6) to your test app; without my component changes, when I open the datepicker the time will be converted to my local time despite setting the default timezone in app.component, but with the changes it shows the correct time.