From:             nickj-phpbugs at nickj dot org
Operating system: Debian Woody GNU/Linux 3.0r6
PHP version:      5CVS-2005-07-02 (dev)
PHP Bug Type:     Date/time related
Bug description:  Should strtotime() ignore the weekday for some inputs? (not 
treat as modifier)

Description:
------------
Should strtotime() ignore the weekday for some inputs, rather than treat
it as a modifier?

Example code:
=================================================
<?php 

print "Should the weekday be treated as part of the time, rather than a
modifier?\n";
$input = "Friday July 1 2005 10:00:00 AM";
print "input: " . $input . "\n";
$tStamp = strtotime($input);
print "date : " . date ("l F j Y H:i:s A", $tStamp) . "\n\n";

print "Should the weekday be treated as part of the time, rather than a
modifier?\n";
$input = "10:00:00 AM Friday July 1 2005";
print "input: " . $input . "\n";
$tStamp = strtotime($input);
print "date : " . date ("H:i:s A l F j Y", $tStamp) . "\n";

?>
=================================================

Actual output:
==================================================
G:\PHP bugs\php5-win32-200507020230>php.exe
..\weekday-as-time-not-modifier\weekday-as-time-not-modifier.php
Should the weekday be treated as part of the time, rather than a
modifier?
input: Friday July 1 2005 10:00:00 AM
date : Friday July 8 2005 10:00:00 AM

Should the weekday be treated as part of the time, rather than a
modifier?
input: 10:00:00 AM Friday July 1 2005
date : 00:00:00 AM Friday July 8 2005

G:\PHP bugs\php5-win32-200507020230>
==================================================

What I thought the output would be:
==================================================
G:\PHP bugs\php5-win32-200507020230>php.exe
..\weekday-as-time-not-modifier\weekday-as-time-not-modifier.php
Should the weekday be treated as part of the time, rather than a
modifier?
input: Friday July 1 2005 10:00:00 AM
date : Friday July 1 2005 10:00:00 AM

Should the weekday be treated as part of the time, rather than a
modifier?
input: 10:00:00 AM Friday July 1 2005
date : 10:00:00 AM Friday July 1 2005

G:\PHP bugs\php5-win32-200507020230>
==================================================

Or, to put it another way: strtotime("Friday July 1 2005 10:00:00 AM")
gives the same results as strtotime("10:00:00 AM", strtotime("Friday",
strtotime("July 1 2005"))), when I would expect it to be equivalent to
strtotime("10:00:00 AM", strtotime("July 1 2005")).

Note: I'm not sure what I would expect to happen if the weekday was the
wrong day (e.g. "Monday July 1 2005 10:00:00 AM"). I think maybe the least
surprising thing would be if the weekday was always ignored for these two
formats (since it's redundant as it can be determined from the date
anyway), same as if the input had been "July 1 2005 10:00:00 AM". And if
someone really did then want to use the "Monday" modifier, they could just
use strtotime("Monday", strtotime("July 1 2005 10:00:00 AM")) to achieve
this.


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

Reply via email to