-
Notifications
You must be signed in to change notification settings - Fork 154
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
Daylight savings time does not seem to be handled correctly. #146
Comments
I wanted to use this library for my ongoing project but I am unsure on how this will handle the DST? |
For my use case I was taking as input a date time string (e.g. |
@hriziya I don't think using the offset strategy vs. a named timezone is really comparable because there are a lot of different timezones that the same offset. For example, lets say you were using a an offset of -7. In the summer months that offset corresponds to America/Whitehorse, America/Vancouver, America/Los_Angeles, among others. In the winter months, that offset corresponds to America/Whitehorse, America/Edmonton, America/Denver, etc. If you're using a fixed offset would not expect DLS to ever really be handled appropriately because DLS is a jurisdiction-by-jurisdiction thing. I think if you use the named timezone, native PHP's DateTime and DateTimeZone classes should handle it properly. |
When creating a new moment at hour when daylight savings changes, Moment returns an invalid date error. Moment.js, on the other hand, returns the changed hour. For example:
$date = new Moment('2017-03-12 02:00:00', 'America/Edmonton);
return an invalid date. However, in moment.js
var now = moment('2017-03-12 02:00:00').format('MMM DD h:mm A');
returns "Mar 12 3:00 AM"
I believe the isValid() is unable to handle the daylight savings hour case.
The text was updated successfully, but these errors were encountered: