php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75975 strftime prints current timezone instead of historical
Submitted: 2018-02-17 05:56 UTC Modified: 2021-01-24 04:22 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: anton at zebooka dot com Assigned: cmb (profile)
Status: No Feedback Package: Date/time related
PHP Version: 7.1.14 OS: macOS 10.13.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
25 - 19 = ?
Subscribe to this entry?

 
 [2018-02-17 05:56 UTC] anton at zebooka dot com
Description:
------------
This function outputs incorrect timezone.
Instead of outputting historical timezone for specified timestamp, it outputs current one.

TZ = Asia/Novosibirsk

We have changed timezone several times in Russia, Novosibirsk.
We dropped DST in 26 of March 2011 and added +1 hour permanently to TZ.
Then in 2014 government decided to move back to "winter time" and -1 hour from timezones. Then in summer 2016 local goverments of several states moved back to "summer time" and added +1 hour.


$ zdump -v /usr/share/zoneinfo/Asia/Novosibirsk | tail -n10
/usr/share/zoneinfo/Asia/Novosibirsk  Sat Oct 30 19:59:59 2010 UTC = Sun Oct 31 02:59:59 2010 +07 isdst=1
/usr/share/zoneinfo/Asia/Novosibirsk  Sat Oct 30 20:00:00 2010 UTC = Sun Oct 31 02:00:00 2010 +06 isdst=0
/usr/share/zoneinfo/Asia/Novosibirsk  Sat Mar 26 19:59:59 2011 UTC = Sun Mar 27 01:59:59 2011 +06 isdst=0
/usr/share/zoneinfo/Asia/Novosibirsk  Sat Mar 26 20:00:00 2011 UTC = Sun Mar 27 03:00:00 2011 +07 isdst=0
/usr/share/zoneinfo/Asia/Novosibirsk  Sat Oct 25 18:59:59 2014 UTC = Sun Oct 26 01:59:59 2014 +07 isdst=0
/usr/share/zoneinfo/Asia/Novosibirsk  Sat Oct 25 19:00:00 2014 UTC = Sun Oct 26 01:00:00 2014 +06 isdst=0
/usr/share/zoneinfo/Asia/Novosibirsk  Sat Jul 23 19:59:59 2016 UTC = Sun Jul 24 01:59:59 2016 +06 isdst=0
/usr/share/zoneinfo/Asia/Novosibirsk  Sat Jul 23 20:00:00 2016 UTC = Sun Jul 24 03:00:00 2016 +07 isdst=0
/usr/share/zoneinfo/Asia/Novosibirsk  Mon Jan 18 03:14:07 2038 UTC = Mon Jan 18 10:14:07 2038 +07 isdst=0
/usr/share/zoneinfo/Asia/Novosibirsk  Tue Jan 19 03:14:07 2038 UTC = Tue Jan 19 10:14:07 2038 +07 isdst=0

strftime() output current +0700 TZ for historical date in 2015 year, although date() function returns correct TZ +0600.

Incorrect:

php > echo strftime('%Y-%m-%d %H:%M:%S %z', strtotime("2015-11-15"));
2015-11-15 00:00:00 +0700

Correct:
php > echo date('Y-m-d H:i:s O', strtotime("2015-11-15"));
2015-11-15 00:00:00 +0600


Test script:
---------------
echo strftime('%Y-%m-%d %H:%M:%S %z', strtotime("2015-11-15"));

Expected result:
----------------
2015-11-15 00:00:00 +0600

Actual result:
--------------
2015-11-15 00:00:00 +0700

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-19 16:31 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2018-02-19 16:31 UTC] cmb@php.net
Isn't +0600 to be expected given the zdump of your database?
 [2018-03-13 03:39 UTC] anton at zebooka dot com
Yes it is. But +0700 is output with strftime, while it should be +0600
 [2018-03-13 12:08 UTC] cmb@php.net
-Status: Feedback +Status: Open -Assigned To: cmb +Assigned To:
 [2018-03-13 12:08 UTC] cmb@php.net
Oops, sorry, the OP was pretty clear about that.
 [2018-03-13 12:48 UTC] derick@php.net
I can't reproduce this:

[PHP: 7.1.15-dev  ] derick@singlemalt:~ $ php -r "date_default_timezone_set('Asia/Novosibirsk'); echo strftime('%Y-%m-%d %H:%M:%S %z', strtotime('2015-11-15'));"
2015-11-15 00:00:00 +0600
 [2018-03-13 13:36 UTC] anton at zebooka dot com
zebooka@zebooka-pro ~ $ uname -a
Darwin zebooka-pro.local 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64

zebooka@zebooka-pro ~ $ php -r "date_default_timezone_set('Asia/Novosibirsk'); echo strftime('%Y-%m-%d %H:%M:%S %z', strtotime('2015-11-15'));"
2015-11-15 00:00:00 +0700

zebooka@zebooka-pro ~ $ php -v
PHP 7.1.14 (cli) (built: Feb  2 2018 08:42:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
 [2021-01-15 14:20 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-01-15 14:20 UTC] cmb@php.net
It appears that this may have been an issue with old timezone
DBs[1].  Anyhow, can you still reproduce this with any of the
actively supported PHP versions[2]?  If so, which timezone DB
version do you use?

[1] <https://3v4l.org/hDXZc>
[2] <https://www.php.net/supported-versions.php>
 [2021-01-24 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 00:01:28 2024 UTC