|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68871 strftime returns wrong timestamp with date_default_timezone_set
Submitted: 2015-01-21 08:04 UTC Modified: 2015-02-01 04:22 UTC
From: ricky at ez2 dot us Assigned:
Status: No Feedback Package: Date/time related
PHP Version: 5.5.20 OS: Ubuntu 14.04 x64
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.
Block user comment
Status: Assign to:
Bug Type:
From: ricky at ez2 dot us
New email:
PHP Version: OS:


 [2015-01-21 08:04 UTC] ricky at ez2 dot us
strftime with %s format returns wrong value.

Test script:
//php.ini date.timezone = Asia/Taipei (UTC +0800)
$time = time();
$time2 = strftime('%s', $time);
if($time != $time2){
    echo "something wrong"; 
    echo "nothing";                

Expected result:

Actual result:
something wrong


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-21 10:35 UTC]
-Package: PHP Language Specification +Package: Date/time related
 [2015-01-21 10:35 UTC]
This has nothing to do with the language specification. Please choose categories accurately.
 [2015-01-21 11:58 UTC]
-Status: Open +Status: Feedback
 [2015-01-21 11:58 UTC]
I can not reproduce this with PHP 5.5.21:

derick@whisky:~ $ cat /tmp/68871.php
$time = time();
$time2 = strftime('%s', $time);
var_dump( $time, $time2 );

derick@whisky:~ $ php -ddate.timezone=Asia/Taipei /tmp/68871.php 
string(10) "1421841507"

What do you see different here?
 [2015-01-21 15:43 UTC] ricky at ez2 dot us
-Status: Feedback +Status: Open
 [2015-01-21 15:43 UTC] ricky at ez2 dot us
I use online php tester,but got wrong result.
 [2015-01-21 18:14 UTC]
-Status: Open +Status: Feedback
 [2015-01-21 18:14 UTC]
What is your TZ environment variable set to?
 [2015-02-01 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-2021 The PHP Group
All rights reserved.
Last updated: Thu Oct 28 05:03:34 2021 UTC