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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 03:02:51 2024 UTC