php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74952 wrong default timezone is set
Submitted: 2017-07-19 11:19 UTC Modified: 2017-07-19 11:40 UTC
From: jihui dot choi at gmail dot com Assigned:
Status: Not a bug Package: PHP options/info functions
PHP Version: 7.0.21 OS: ubuntu linux
Private report: No CVE-ID: None
 [2017-07-19 11:19 UTC] jihui dot choi at gmail dot com
Description:
------------
I installed ubuntu linux on my computer with Asia/Seoul timezone.
no problems with it. date command on cli show perfectly correct time.

however on php, date function(or object) shows the time of Pyongyang, unless I change date.timezone manually in php.ini.



Test script:
---------------
$ date

$ php -r "echo date('Y-m-d H:i:s');"

$ php -r "print_r(new Datetime());"


Expected result:
----------------
the default timezone of php should be followed the system setting correctly.

$ date
Wed Jul 19 20:12:05 KST 2017

$ php -r "echo date('Y-m-d H:i:s');"
2017-07-19 20:12:05

$ php -r "print_r(new Datetime());"
DateTime Object
(
    [date] => 2017-07-19 20:12:05.000000
    [timezone_type] => 3
    [timezone] => Asia/Seoul
)

Actual result:
--------------
$ date
Wed Jul 19 20:12:05 KST 2017

$ php -r "echo date('Y-m-d H:i:s');"
2017-07-19 19:42:01

$ php -r "print_r(new Datetime());"
DateTime Object
(
    [date] => 2017-07-19 19:42:21.000000
    [timezone_type] => 3
    [timezone] => Asia/Pyongyang
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-19 11:40 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2017-07-19 11:40 UTC] derick@php.net
PHP does not guess the time zone identifier from the operating system, and unless date.timezone is set, it will use UTC.

If you check phpinfo() output, and see "0.System" show for «"Olson" Timezone Database Version», it means you have a patched version of PHP (Ubuntu, and other distributions do that). As this is not something we endorse, you need to talk to Ubuntu support.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 20:01:29 2024 UTC