note 79676 deleted from function.date by felipe
| From: | felipe@php.net | Date: | Sun, 09 Dec 2007 13:14:35 +0000 |
| Subject: | note 79676 deleted from function.date by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-132979@lists.php.net to get a copy of this message | ||
Note Submitter: andrew dot myers at civicwifi dot com
----
If the second parameter is non-numeric, then PHP 5 will return FALSE, but PHP 4 will treat it as a 0
and return the Unix Epoch for your timezone.
Also, beware the difference between the return values of strtotime() in PHP 5 vs. PHP 4.
<?php
$from_empty = date("Y-m-d H:i:s", "");
var_dump($from_empty);
// PHP 5 >>> Warning: date() expects parameter 2 to be long, string given...
// bool(false)
// PHP 4 >>> string(19) "1969-12-31 18:00:00"
$from_bogus = date("Y-m-d H:i:s", "bogus");
var_dump($from_bogus);
// PHP 5 >>> Warning: date() expects parameter 2 to be long, string given...
// bool(false)
//PHP 4 >>> string(19) "1969-12-31 18:00:00"
$from_bad_strtotime = date("Y-m-d H:i:s", strtotime("Oops, bad data"));
var_dump($from_bad_strtotime);
// PHP 5 >>> string(19) "1969-12-31 18:00:00"
// PHP 4 >>> string(19) "1969-12-31 17:59:59"
?>