ID:               33532
 Updated by:       [EMAIL PROTECTED]
 Reported By:      nickj-phpbugs at nickj dot org
 Status:           Assigned
 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:

Yeha, but this is a strftime() problem, not a date() problem ;-)


Previous Comments:
------------------------------------------------------------------------

[2005-07-01 09:38:52] [EMAIL PROTECTED]

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

Reply via email to