note 57258 modified in function.strtotime by derick
| From: | derick@php.net | Date: | Sat, 08 Oct 2005 12:55:19 +0000 |
| Subject: | note 57258 modified in function.strtotime by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96669@lists.php.net to get a copy of this message | ||
The PHP 5.1.0 change is a major backward compatibility break.
Now, that the returned value on failure has changed, the correct way to detect problems on all PHP
versions is:
<?php
if (($time = strtotime($date)) == -1 || $time === false) {
die 'Invalid date';
}
?>
[red (derick): note, this is not 100% correct, as in this case 1969-12-31 23:59 will be thrown out
as that timestamp is "-1"]
--was--
The PHP 5.1.0 change is a major backward compatibility break.
Now, that the returned value on failure has changed, the correct way to detect problems on all PHP
versions is:
<?php
if (($time = strtotime($date)) == -1 || $time === false) {
die 'Invalid date';
}
?>
http://php.net/manual/en/function.strtotime.php