Bug #68871 [Opn->Fbk]: strftime returns wrong timestamp with date_default_timezone_set

From: Date: Wed, 21 Jan 2015 18:14:11 +0000
Subject: Bug #68871 [Opn->Fbk]: strftime returns wrong timestamp with date_default_timezone_set
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190117@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68871&edit=1

 ID:                 68871
 Updated by:         aharvey@php.net
 Reported by:        ricky at ez2 dot us
 Summary:            strftime returns wrong timestamp with
                     date_default_timezone_set
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            Date/time related
 Operating System:   Ubuntu 14.04 x64
 PHP Version:        5.5.20
 Block user comment: N
 Private report:     N

 New Comment:

What is your TZ environment variable set to?


Previous Comments:
------------------------------------------------------------------------
[2015-01-21 15:43:22] ricky at ez2 dot us

I use online php tester,but got wrong result.

http://sandbox.onlinephpfunctions.com/code/d41ddc29adee7a0f4aba6e4dd587c2ddee33c1a0

------------------------------------------------------------------------
[2015-01-21 11:58:49] derick@php.net

I can not reproduce this with PHP 5.5.21:

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

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

What do you see different here?

------------------------------------------------------------------------
[2015-01-21 10:35:40] ajf@php.net

This has nothing to do with the language specification. Please choose categories accurately.

------------------------------------------------------------------------
[2015-01-21 08:04:39] ricky at ez2 dot us

Description:
------------
strftime with %s format returns wrong value.

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

Expected result:
----------------
nothing

Actual result:
--------------
something wrong


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=68871&edit=1


Thread (1 message)

  • aharvey@php.net
  • Unknown Message
    • aharvey@php.net
« previous php.bugs (#190117) next »