#33532 [Asn->Csd]: Different output for strftime() and date()
| From: | derick@php.net | Date: | Sun, 03 Jul 2005 19:15:16 +0000 |
| Subject: | #33532 [Asn->Csd]: Different output for strftime() and date() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-81323@lists.php.net to get a copy of this message | ||
ID: 33532
Updated by: derick@php.net
Reported By: nickj-phpbugs at nickj dot org
-Status: Assigned
+Status: Closed
Bug Type: Date/time related
Operating System: Debian Woody GNU/Linux 3.0r6
PHP Version: 5CVS-2005-07-01 (dev)
Assigned To: derick
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Should be fixed in CVS now.
Previous Comments:
------------------------------------------------------------------------
[2005-07-01 10:15:22] derick@php.net
Yeha, but this is a strftime() problem, not a date() problem ;-)
------------------------------------------------------------------------
[2005-07-01 09:38:52] sniper@php.net
Derick was working on a new *date() implementation too..
------------------------------------------------------------------------
[2005-07-01 06:15:47] nickj-phpbugs at nickj dot org
Description:
------------
Getting different output for strftime() and date(), and wondering
whether these should be the same.
Example code:
<?php
print "TZ has NOT been set\n";
print "Should strftime==datestr? Strftime seems to assume GMT
tStamp.\n";
$input = "10:00:00 AM July 1 2005";
print "input " . $input . "\n";
$tStamp = strtotime($input);
print "strftime " . strftime("%r %B%e %Y", $tStamp) . "\n";
print "datestr " . date ("H:i:s A F j Y", $tStamp) . "\n";
print "\nSetting TZ\n";
putenv ("TZ=Australia/Sydney");
$input = "10:00:00 AM July 1 2005";
print "input " . $input . "\n";
$tStamp = strtotime($input);
print "strftime " . strftime("%r %B%e %Y", $tStamp) . "\n";
print "datestr " . date ("H:i:s A F j Y", $tStamp) . "\n";
?>
Output:
-------------------------------------------------
ludo:~/tmp/php-5.1-dev/strftime-vs-date#
../php5-200507010030/sapi/cli/php ./strftime-vs-date.php
TZ has NOT been set
Should strftime==datestr? Strftime seems to assume GMT tStamp.
input 10:00:00 AM July 1 2005
strftime 08:00:00 PM July 1 2005
datestr 10:00:00 AM July 1 2005
Setting TZ
input 10:00:00 AM July 1 2005
strftime 10:00:00 AM July 1 2005
datestr 10:00:00 AM July 1 2005
ludo:~/tmp/php-5.1-dev/strftime-vs-date#
-------------------------------------------------
Expected output:
-------------------------------------------------
TZ has NOT been set
Should strftime==datestr? Strftime seems to assume GMT tStamp.
input 10:00:00 AM July 1 2005
strftime 10:00:00 AM July 1 2005
datestr 10:00:00 AM July 1 2005
Setting TZ
input 10:00:00 AM July 1 2005
strftime 10:00:00 AM July 1 2005
datestr 10:00:00 AM July 1 2005
ludo:~/tmp/php-5.1-dev/strftime-vs-date#
-------------------------------------------------
Note: the "%r" strftime format is described thus: "time in a.m. and
p.m. notation". The strftime documentation does not indicate that this
is altered by the locale settings (unlike the weekday, month, and so on
are). However my locale is English anyway, which is what date() seems to
use, and the locale is not adjusted by the above script, so I would
anticipate getting the same output between date and strftime.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33532&edit=1