Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > #34771 : strtotime() fails with 1-12am/pm
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 18th April 07:36
php-bugs
External User
 
Posts: 1
Default #34771 : strtotime() fails with 1-12am/pm



From: arpad at rajeczy dot com
Operating system: Windows XP
PHP version: 5.1.0RC1
PHP Bug Type: Date/time related
Bug description: strtotime() fails with 1-12am/pm

Description:
------------
strtotime() now returns false for input like '12am', where the minutes are
omitted with am, pm, a.m. or p.m.

This should be allowed according to the GNU date input formats:
http://www.gnu.org/software/tar/manual/html_chapter/tar_7.html#SEC112

It works correctly in 4.3.10, 4.4.0 and 5.0.4.
It fails in 5.1.0RC1, built Aug 16 2005 13:49:49 and 5.1.0RC2-dev, built
Oct 6 2005 20:17:56.

Reproduce code:
---------------
<pre><?php

$tests = array(
'12am', '1am', '1pm',
'12a.m.', '1a.m.', '1p.m.',
'12:00am', '1:00am', '1:00pm',
'12:00a.m.', '1:00a.m.', '1:00p.m.'
);

foreach ($tests as $test) {
$t = strtotime($test);
printf("%-10s => %-15s => %s\n", $test, var_export($t, 1), date('r',
$t));
}

?></pre>

Expected result:
----------------
12am => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1am => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1pm => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12a.m. => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1a.m. => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1p.m. => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12:00am => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00am => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00pm => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12:00a.m. => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00a.m. => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00p.m. => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000

Actual result:
--------------
12am => false => Thu, 01 Jan 1970 00:00:00 +0000
1am => false => Thu, 01 Jan 1970 00:00:00 +0000
1pm => false => Thu, 01 Jan 1970 00:00:00 +0000
12a.m. => false => Thu, 01 Jan 1970 00:00:00 +0000
1a.m. => false => Thu, 01 Jan 1970 00:00:00 +0000
1p.m. => false => Thu, 01 Jan 1970 00:00:00 +0000
12:00am => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00am => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00pm => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12:00a.m. => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00a.m. => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00p.m. => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000

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


  sponsored links


2 18th April 10:42
External User
 
Posts: 1
Default #34771 : strtotime() fails with 1-12am/pm



ID: 34771
Updated by: sniper@php.net
Reported By: arpad at rajeczy dot com
-Status: Open
+Status: Feedback
Bug Type: Date/time related
Operating System: Windows XP
PHP Version: 5.1.0RC1
New Comment:

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


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

[2005-10-07 04:30:52] arpad at rajeczy dot com

Description:
------------
strtotime() now returns false for input like '12am', where the minutes
are omitted with am, pm, a.m. or p.m.

This should be allowed according to the GNU date input formats:
http://www.gnu.org/software/tar/manual/html_chapter/tar_7.html#SEC112

It works correctly in 4.3.10, 4.4.0 and 5.0.4.
It fails in 5.1.0RC1, built Aug 16 2005 13:49:49 and 5.1.0RC2-dev,
built Oct 6 2005 20:17:56.

Reproduce code:
---------------
<pre><?php

$tests = array(
'12am', '1am', '1pm',
'12a.m.', '1a.m.', '1p.m.',
'12:00am', '1:00am', '1:00pm',
'12:00a.m.', '1:00a.m.', '1:00p.m.'
);

foreach ($tests as $test) {
$t = strtotime($test);
printf("%-10s => %-15s => %s\n", $test, var_export($t, 1),
date('r', $t));
}

?></pre>

Expected result:
----------------
12am => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1am => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1pm => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12a.m. => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1a.m. => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1p.m. => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12:00am => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00am => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00pm => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12:00a.m. => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00a.m. => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00p.m. => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000

Actual result:
--------------
12am => false => Thu, 01 Jan 1970 00:00:00 +0000
1am => false => Thu, 01 Jan 1970 00:00:00 +0000
1pm => false => Thu, 01 Jan 1970 00:00:00 +0000
12a.m. => false => Thu, 01 Jan 1970 00:00:00 +0000
1a.m. => false => Thu, 01 Jan 1970 00:00:00 +0000
1p.m. => false => Thu, 01 Jan 1970 00:00:00 +0000
12:00am => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00am => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00pm => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12:00a.m. => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00a.m. => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00p.m. => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=34771&edit=1
  Reply With Quote
3 18th April 10:43
External User
 
Posts: 1
Default #34771 : strtotime() fails with 1-12am/pm


ID: 34771
Updated by: derick@php.net
Reported By: arpad at rajeczy dot com
-Status: Feedback
+Status: Assigned
Bug Type: Date/time related
Operating System: Windows XP
PHP Version: 5.1.0RC1
-Assigned To:
+Assigned To: derick


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

[2005-10-07 09:21:22] sniper@php.net

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

------------------------------------------------------------------------

[2005-10-07 04:30:52] arpad at rajeczy dot com

Description:
------------
strtotime() now returns false for input like '12am', where the minutes
are omitted with am, pm, a.m. or p.m.

This should be allowed according to the GNU date input formats:
http://www.gnu.org/software/tar/manual/html_chapter/tar_7.html#SEC112

It works correctly in 4.3.10, 4.4.0 and 5.0.4.
It fails in 5.1.0RC1, built Aug 16 2005 13:49:49 and 5.1.0RC2-dev,
built Oct 6 2005 20:17:56.

Reproduce code:
---------------
<pre><?php

$tests = array(
'12am', '1am', '1pm',
'12a.m.', '1a.m.', '1p.m.',
'12:00am', '1:00am', '1:00pm',
'12:00a.m.', '1:00a.m.', '1:00p.m.'
);

foreach ($tests as $test) {
$t = strtotime($test);
printf("%-10s => %-15s => %s\n", $test, var_export($t, 1),
date('r', $t));
}

?></pre>

Expected result:
----------------
12am => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1am => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1pm => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12a.m. => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1a.m. => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1p.m. => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12:00am => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00am => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00pm => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12:00a.m. => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00a.m. => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00p.m. => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000

Actual result:
--------------
12am => false => Thu, 01 Jan 1970 00:00:00 +0000
1am => false => Thu, 01 Jan 1970 00:00:00 +0000
1pm => false => Thu, 01 Jan 1970 00:00:00 +0000
12a.m. => false => Thu, 01 Jan 1970 00:00:00 +0000
1a.m. => false => Thu, 01 Jan 1970 00:00:00 +0000
1p.m. => false => Thu, 01 Jan 1970 00:00:00 +0000
12:00am => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00am => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00pm => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12:00a.m. => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00a.m. => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00p.m. => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=34771&edit=1
  Reply With Quote
4 18th April 10:43
External User
 
Posts: 1
Default #34771 : strtotime() fails with 1-12am/pm


ID: 34771
Updated by: derick@php.net
Reported By: arpad at rajeczy dot com
-Status: Assigned
+Status: Closed
Bug Type: Date/time related
Operating System: Windows XP
PHP Version: 5.1.0RC1
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.


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

[2005-10-07 09:21:22] sniper@php.net

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

------------------------------------------------------------------------

[2005-10-07 04:30:52] arpad at rajeczy dot com

Description:
------------
strtotime() now returns false for input like '12am', where the minutes
are omitted with am, pm, a.m. or p.m.

This should be allowed according to the GNU date input formats:
http://www.gnu.org/software/tar/manual/html_chapter/tar_7.html#SEC112

It works correctly in 4.3.10, 4.4.0 and 5.0.4.
It fails in 5.1.0RC1, built Aug 16 2005 13:49:49 and 5.1.0RC2-dev,
built Oct 6 2005 20:17:56.

Reproduce code:
---------------
<pre><?php

$tests = array(
'12am', '1am', '1pm',
'12a.m.', '1a.m.', '1p.m.',
'12:00am', '1:00am', '1:00pm',
'12:00a.m.', '1:00a.m.', '1:00p.m.'
);

foreach ($tests as $test) {
$t = strtotime($test);
printf("%-10s => %-15s => %s\n", $test, var_export($t, 1),
date('r', $t));
}

?></pre>

Expected result:
----------------
12am => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1am => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1pm => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12a.m. => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1a.m. => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1p.m. => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12:00am => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00am => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00pm => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12:00a.m. => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00a.m. => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00p.m. => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000

Actual result:
--------------
12am => false => Thu, 01 Jan 1970 00:00:00 +0000
1am => false => Thu, 01 Jan 1970 00:00:00 +0000
1pm => false => Thu, 01 Jan 1970 00:00:00 +0000
12a.m. => false => Thu, 01 Jan 1970 00:00:00 +0000
1a.m. => false => Thu, 01 Jan 1970 00:00:00 +0000
1p.m. => false => Thu, 01 Jan 1970 00:00:00 +0000
12:00am => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00am => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00pm => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000
12:00a.m. => 1128643200 => Fri, 07 Oct 2005 00:00:00 +0000
1:00a.m. => 1128646800 => Fri, 07 Oct 2005 01:00:00 +0000
1:00p.m. => 1128690000 => Fri, 07 Oct 2005 13:00:00 +0000


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=34771&edit=1
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666