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

Comparing fails when using timezones #148

Open
wsd-msp opened this issue May 16, 2018 · 0 comments
Open

Comparing fails when using timezones #148

wsd-msp opened this issue May 16, 2018 · 0 comments

Comments

@wsd-msp
Copy link

wsd-msp commented May 16, 2018

When comparing two dates of the same timezone where one of them is closer to 00:00 than the timezone offset, isSame and isBefore will return the wrong result when comparing by day:

$date = new \Moment\Moment('2018-05-16 00:30:00', 'Europe/Copenhagen');
$date2 = new \Moment\Moment('2018-05-16 22:00:00', 'Europe/Copenhagen');

echo 'Is same day: '.($date->isSame($date2, 'day')?'Yes':'No');

Expected output:
Is same day: Yes

Actual output:
Is same day: No

After inspecting the code, i found out it's due to the fact that the dates is converted to UTC before calling startOf($period).

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

1 participant