Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Wrong offset for Timezones #45451

Closed
Closed
@Lenny4

Description

@Lenny4

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions