ID: 33456
Comment by: nickj-phpbugs at nickj dot org
Reported By: serge at skycomp dot ca
Status: Assigned
Bug Type: Date/time related
Operating System: Linux
PHP Version: 4.3.11
Assigned To: derick
New Comment:
Some corrections, updates, relevant information, and then questions for
PHP-5.1-dev:
=================================================================
Correction - This line:
'%r %B %e %Y', // remove the '%A' (day): -2 hours
Should say this instead:
'%r %B %e %Y', // remove the '%A' (day): -14 hours
=================================================================
Using this format string on PHP-5.1-dev leads to no change:
'%r %B %e %Y %z' // Add the timezone: No change.
=================================================================
Please see this comment at http://php.net/strftime about why 'at'
cannot be used:
The description of strtotime says that it can "Parse about any English
textual datetime description into a UNIX timestamp". Be careful,
however, when using "plain English". I was puzzled over why
strtotime("June 23, 2003 at 12:00PM") returned a timestamp
corresponding to 9:00 AM Central Time, until I realized the "at" was
being interpreted as Azores Time or GMT+002. Writing strtotime("June
23, 2003 12:00PM") returned the correct timestamp.
=================================================================
Also I think Derick Rethans has recently checked in the new strtotime()
implementation in PHP-5.1-dev, so may get different results between
5.1-dev and PHP4.
=================================================================
So the only unresolved questions I have for strtotime() in PHP-5.1-dev
are whether these 3 formats should work:
- '%A %B %e %Y %r'
e.g.: 'Friday July 1 2005 10:00:00 AM'
shouldn't the weekday be assumed to be part of the format string,
rather than a modifier?
shouldn't the current timezone be assumed, rather than GMT?
- '%r %A %B %e %Y'
e.g. '10:00:00 AM Friday July 1 2005'
shouldn't the weekday be assumed to be part of the format string,
rather than a modifier?
shouldn't the current timezone be assumed, rather than GMT?
- '%r %B %e %Y'
e.g. '10:00:00 AM July 1 2005'
shouldn't the current timezone be assumed, rather than GMT?
Previous Comments:
------------------------------------------------------------------------
[2005-06-25 02:20:19] nickj-phpbugs at nickj dot org
Results of testing on PHP-5.1-dev CVS (php5-200506222230), with various
format strings:
==============================================================
<?php
$formats = array ( // CHANGE : RESULT ON PHP-5.1-DEV
'%A, %B %e %Y at %r',// original: +1 week +12 hours
'%A %B %e %Y at %r', // remove comma: +1 week +12 hours
'%A %B %e %Y %r', // remove 'at': +1 week -2 hours
'%r %A %B %e %Y', // move %r to front: +1 week
'%r %B %e %Y' // remove the '%A' (day): -2 hours
);
foreach ($formats as $format) {
print "-------- $format -----------\n";
$timestr="Friday at 7pm";
print "Starting Value: '$timestr'\n";
for($x=1; $x<=10; $x++) {
$tStamp = strtotime($timestr);
$timestr=strftime($format,$tStamp);
print "x: $x; timestr: '$timestr'; tStamp: $tStamp\n";
}
}
?>
------------------------------------------------------------------------
[2005-06-24 01:10:38] serge at skycomp dot ca
Ok I'll see about testing it agains the latest CVS if I have a chance.
A 100% php example is as follows:
<?
$timestr="Friday at 7pm";
print "Starting Value: '$timestr'\n";
for( $x=1; $x<=10; $x++) {
$timestr=strftime('%A, %B %e %Y at %r',strtotime($timestr));
print "The string is now: '$timestr'\n";
}
?>
------------------------------------------------------------------------
[2005-06-24 00:58:40] [EMAIL PROTECTED]
Right. And I didn't ask you to upgrade the server. I asked to to try
the latest snapshot.
And I'd really appreciate if you provide a reproduce code without
HTML/forms/etc. Just a plain, short and clean PHP code that
demonstrates the problem.
Thanks in advance.
------------------------------------------------------------------------
[2005-06-24 00:55:09] serge at skycomp dot ca
This server does not run php5. It's on php4
------------------------------------------------------------------------
[2005-06-24 00:48:26] [EMAIL PROTECTED]
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/33456
--
Edit this bug report at http://bugs.php.net/?id=33456&edit=1