note 79676 added to function.date
| From: | andrew dot myers at civicwifi dot com | Date: | Fri, 07 Dec 2007 17:22:37 +0000 |
| Subject: | note 79676 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132932@lists.php.net to get a copy of this message | ||
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"
?>
----
Server IP: 69.147.83.197
Probable Submitter: 208.75.96.17
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/79676
Del: integrated -- https://master.php.net/note/delete/79676/integrated
Del: useless -- https://master.php.net/note/delete/79676/useless
Del: bad code -- https://master.php.net/note/delete/79676/bad+code
Del: spam -- https://master.php.net/note/delete/79676/spam
Del: non-english -- https://master.php.net/note/delete/79676/non-english
Del: in docs -- https://master.php.net/note/delete/79676/in+docs
Del: other reasons-- https://master.php.net/note/delete/79676
Reject -- https://master.php.net/note/reject/79676
Search -- https://master.php.net/manage/user-notes.php