php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64824 date_default_timezone_set('UTC') bug
Submitted: 2013-05-12 19:23 UTC Modified: 2013-05-12 21:14 UTC
From: daliuskal at gmail dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 5.3.25 OS: CentOS release 5.9 (Final)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: daliuskal at gmail dot com
New email:
PHP Version: OS:

 

 [2013-05-12 19:23 UTC] daliuskal at gmail dot com
Description:
------------
date_default_timezone_set('UTC') is not working as expected, date function returns 
time with -14400 seconds (-4 hours) from UTC.

I've run into this problem after moving into new server, had to set default 
timezone to GMT instead of UTC for the code to work correctly.

Test script:
---------------
$time = time();

date_default_timezone_set('UTC');
echo (date('h', $time) - gmdate('h', $time));

date_default_timezone_set('GMT');
echo "\n".(date('h', $time) - gmdate('h', $time));

Expected result:
----------------
0
0

Actual result:
--------------
-4
0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-12 21:14 UTC] daliuskal at gmail dot com
-Status: Open +Status: Closed
 [2013-05-12 21:14 UTC] daliuskal at gmail dot com
phpinfo() showed "Olson" Timezone Database Version as 0.system, so I used the 
command

$ pecl upgrade timezonedb

and added

extension=timezonedb.so
to php.ini

After restarting the server, the problem has been resolved with the new timezone 
DB version 2013.3
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jun 02 21:01:27 2025 UTC