8000 Wrong offset for Timezones · Issue #45451 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Wrong offset for Timezones #45451

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

Closed
Lenny4 opened this issue Feb 16, 2022 · 4 comments
Closed

Wrong offset for Timezones #45451

Lenny4 opened this issue Feb 16, 2022 · 4 comments

Comments

@Lenny4
Copy link
Contributor
Lenny4 commented Feb 16, 2022

Symfony version(s) affected

6.0.3

Description

I'm using Timezones like this:

Timezones::getGmtOffset('Europe/Paris', (new DateTime('2022-02-16 00:00:00'))->getTimestamp()); // result: GMT+02:00

But when I'm looking on google I got this:
image

It's not the same GMT.

In the documentation example it take the "time change" correctly for Madrid:

$offset = Timezones::getGmtOffset('Europe/Madrid', strtotime('October 27, 2019')); // $offset = 'GMT+02:00'
$offset = Timezones::getGmtOffset('Europe/Madrid', strtotime('October 28, 2019')); // $offset = 'GMT+01:00'

But when I try it I got:

$offset = Timezones::getGmtOffset('Europe/Madrid', strtotime('October 27, 2019')); // $offset = 'GMT+02:00'
$offset = Timezones::getGmtOffset('Europe/Madrid', strtotime('October 28, 2019')); // $offset = 'GMT+02:00'

How to reproduce

<?php

use Symfony\Component\Intl\Timezones;

class OffsetClass
{
    public static function getOffsetGmt(): bool
    {
        return
            Timezones::getGmtOffset('Europe/Madrid', strtotime('October 27, 2019'))
            !==
            Timezones::getGmtOffset('Europe/Madrid', strtotime('October 28, 2019'));
    }
}

OffsetClass::getOffsetGmt();

Possible Solution

No response

Additional Context

I'm running my symfony application in a docker FROM php:8.1-fpm-alpine

@ro0NL
Copy link
Contributor
ro0NL commented Feb 17, 2022

This is odd ...

PHP 7.4

^ "GMT+01:00"
root@a5e41dd4773c:/app# php -i | grep -i timezone
"Olson" Timezone Database Version => 2021.5
Timezone Database => internal
Default timezone => UTC
date.timezone => no value => no value

PHP 8.1

^ "GMT+02:00"
root@a838caa14794:/app# php -i | grep -i timezone
"Olson" Timezone Database Version => 2021.5
Timezone Database => internal
Default timezone => UTC
date.timezone => no value => no value

@Lenny4
Copy link
Contributor Author
Lenny4 commented Feb 17, 2022

Closing since it's not related to symfony.

I created this issue.

php/php-src#8108

@Lenny4 Lenny4 closed this as completed Feb 17, 2022
@Lenny4
Copy link
Contributor Author
Lenny4 commented Feb 17, 2022

Maybe implement the @heiglandreas solution provided here: php/php-src#8108

@Lenny4 Lenny4 reopened this Feb 17, 2022
@nicolas-grekas
Copy link
Member

Up for sending a PR @Lenny4?

nicolas-grekas added a commit that referenced this issue Feb 18, 2022
This PR was merged into the 4.4 branch.

Discussion
----------

[Intl] fix wrong offset timezone PHP 8.1

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #45451
| License       | MIT
| Doc PR        | -

Commits
-------

8512385 [Intl] fix wrong offset timezone PHP 8.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0