From:             nickj-phpbugs at nickj dot org
Operating system: Debian Woody GNU/Linux 3.0r6
PHP version:      5CVS-2005-07-01 (dev)
PHP Bug Type:     Date/time related
Bug description:  Different output for strftime() and date()

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 bug report at http://bugs.php.net/?id=33532&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33532&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33532&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33532&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33532&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33532&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33532&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33532&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33532&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33532&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33532&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=33532&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=33532&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33532&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33532&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33532&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33532&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33532&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33532&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33532&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33532&r=mysqlcfg

Reply via email to