note 99149 modified in function.strtotime by derick
| From: | derick@php.net | Date: | Sun, 14 Dec 2014 11:22:38 +0000 |
| Subject: | note 99149 modified in function.strtotime by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-201147@lists.php.net to get a copy of this message | ||
UK dates (eg. 27/05/1990) won't work with strotime, even with timezone properly set.
/*
However, if you just replace "/" with "-" it will work fine.
<?php
$timestamp = strtotime(str_replace('/', '-', '27/05/1990'));
?>
*/
[red., derick]: What you instead should do is:
<?php
$date = date_create_from_format('d/m/y', '27/05/1990');
?>
That does not make it a timestamp, but a DateTime object, which is much more versatile instead.
--was--
UK dates (eg. 27/05/1990) won't work with strotime, even with timezone properly set.
However, if you just replace "/" with "-" it will work fine.
<?php
$timestamp = strtotime(str_replace('/', '-', '27/05/1990'));
?>
http://php.net/manual/en/function.strtotime.php