php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43856 mktime and strftime use different timezones
Submitted: 2008-01-15 15:17 UTC Modified: 2008-03-13 16:01 UTC
From: john at jcoppens dot com Assigned: derick (profile)
Status: Not a bug Package: Date/time related
PHP Version: 5.2.5 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: john at jcoppens dot com
New email:
PHP Version: OS:

 

 [2008-01-15 15:17 UTC] john at jcoppens dot com
Description:
------------
mktime() and strftime use different timezones...

Reproduce code:
---------------
echo "time() = " . time() .
         " \nstrftime = ", strftime("%T %Z %z") .
         " \nGMT offset = " . mktime(0, 0, 0, 1, 1, 1970) .
         "\n";;


Expected result:
----------------
time() = 1200409896 
strftime = 13:11:36 ARST -0200 
GMT offset = 7200

Actual result:
--------------
time() = 1200409896 
strftime = 13:11:36 ARST -0200 
GMT offset = 10800

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-31 20:36 UTC] derick@php.net
What's the output of this script:

<?php
error_reporting( E_ALL | E_STRICT );

echo date_default_timezone_get(), "\n";

echo "time() = " . time() .
    " \nstrftime = ", strftime("%T %Z %z") .
    " \nGMT offset = " . mktime(0, 0, 0, 1, 1, 1970) .
    "\n";
?>

 [2008-02-01 01:11 UTC] john at jcoppens dot com
Output of script:

PHP Strict Standards:  date_default_timezone_get(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Buenos_Aires' for 'ARST/-2.0/DST' instead in /root/- on line 4
America/Buenos_Aires
time() = 1201827963 
strftime = PHP Strict Standards:  strftime(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Buenos_Aires' for 'ARST/-2.0/DST' instead in /root/- on line 9
PHP Strict Standards:  mktime(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Buenos_Aires' for 'ARST/-2.0/DST' instead in /root/- on line 9
23:06:03 ARST -0200 
GMT offset = 10800

Do note that I have updated the zoneinfo of the system, and the 
way to define the time zone is now

Amertica/Argentina/Cordoba

I noticed that is some systems the Argentina directory was added,
but the old BuenosAires etc files were not removed in the
America level (BuenosAires, Cordoba, Jujuy, SanJuan, and a couple
others.

John
 [2008-02-01 01:29 UTC] john at jcoppens dot com
That was a typo, it must be:

America/Argentina/Cordoba

John
 [2008-03-13 16:01 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

You need to install the pecl/timezonedb extension.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 05:01:29 2024 UTC