php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29342 strtotime(null) does not return -1
Submitted: 2004-07-22 23:09 UTC Modified: 2004-07-28 03:45 UTC
From: php dot net at gurugeek dot com Assigned:
Status: Closed Package: Date/time related
PHP Version: 5.0.0 OS: RHEL 3.0
Private report: No CVE-ID:
 [2004-07-22 23:09 UTC] php dot net at gurugeek dot com
Description:
------------
Executing strtotime(null) returns midnight of the current day. The same happens with strtotime(false).

[jrod@nagios01 libexec]$ php -r 'echo strtotime(null) . "\n";'
1090479600
[jrod@nagios01 libexec]$ php -r 'echo date("r", strtotime(null)) . "\n";'
Thu, 22 Jul 2004 00:00:00 -0700


Reproduce code:
---------------
echo strtotime(null);
echo strtotime("");

Expected result:
----------------
-1

Actual result:
--------------
Midnight of the current day:
Thu, 22 Jul 2004 00:00:00 -0700


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-28 03:45 UTC] iliaa@php.net
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.


 [2004-08-24 21:22 UTC] kevin at brucecreative dot com
Is there a bug with strtotime in 5.0.1? strtotime("+11 
minutes") doesn't work, when it worked fine in 4.x
 [2004-09-13 20:55 UTC] jonathant at digbang dot com
error report:
Now (php 5.0.1) when you send null as a parameter to strtotime() it returns an error instead of -1
 [2004-10-12 18:20 UTC] marcus at synchromedia dot co dot uk
I'm running PHP5.0.2, and I'm seeing a very similar bug:

<?php
print date('r', strtotime('now'))."\n";
print date('r', strtotime('now +1 hour'))."\n";
print date('r', strtotime('+1 hour', time()))."\n";
?>

under PHP 4.3.9 this gives:

Tue, 12 Oct 2004 17:16:04 +0100
Tue, 12 Oct 2004 18:16:04 +0100
Tue, 12 Oct 2004 18:16:04 +0100

Under PHP 5.0.2:

Tue, 12 Oct 2004 00:00:00 +0100
Tue, 12 Oct 2004 01:00:00 +0100
Tue, 12 Oct 2004 01:00:00 +0100

so the description of this bug could be expanded to:
strtotime returns times relative to midnight of current 
day instead of requested time.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 24 02:02:10 2014 UTC