Skip to content

UTC Default timezone instead of server local timezone ? #11496

@Wait4Code

Description

@Wait4Code

Description

After upgrading my php version from 8.1 to 8.2 I've noticed that the default timezone changed from the server local to UTC.
To be sure that it does not come from my server setup or my computer, i've set up 2 differents Dockerfile based on Ubuntu 22.04 and based on the same local timezone : one with php 8.1 and another with php 8.2.

The one with PHP 8.1 correctly use the container TZ while the other one use UTC.

I've also noticed the same behaviour with Ubuntu 18.04 and 20.04.

Is that a new behaviour of PHP8.2 ? Am I missing something ?

Be aware that php.ini config files are left untouched, they are by default.

Here are the Dockerfiles

PHP 8.1 :

FROM ubuntu:22.04

RUN apt-get update --fix-missing
RUN apt-get install -y software-properties-common

RUN apt-get update && \
    apt-get install -yq tzdata && \
    ln -fs /usr/share/zoneinfo/Europe/Berlin /etc/localtime && \
    dpkg-reconfigure -f noninteractive tzdata

RUN add-apt-repository -y ppa:ondrej/php
RUN apt update
RUN apt install -y php8.1


CMD date; php -r 'print_r(new \DateTime("now"));'

Output :

Wed Jun 21 08:00:22 CEST 2023
DateTime Object
(
    [date] => 2023-06-21 08:00:22.532719
    [timezone_type] => 3
    [timezone] => Europe/Berlin
)

PHP 8.2 :

FROM ubuntu:22.04

RUN apt-get update --fix-missing
RUN apt-get install -y software-properties-common

RUN apt-get update && \
    apt-get install -yq tzdata && \
    ln -fs /usr/share/zoneinfo/Europe/Berlin /etc/localtime && \
    dpkg-reconfigure -f noninteractive tzdata

RUN add-apt-repository -y ppa:ondrej/php
RUN apt update
RUN apt install -y php8.2


CMD date; php -r 'print_r(new \DateTime("now"));'

Output :

Wed Jun 21 08:00:16 CEST 2023
DateTime Object
(
    [date] => 2023-06-21 06:00:16.449674
    [timezone_type] => 3
    [timezone] => UTC
)

PHP Version

PHP 8.2

Operating System

Ubuntu 22.04

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