note 99149 deleted from function.strtotime by crell
| From: | crell@php.net | Date: | Thu, 30 Jun 2022 20:07:52 +0000 |
| Subject: | note 99149 deleted from function.strtotime by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218799@lists.php.net to get a copy of this message | ||
Note Submitter: Stefan Kunstmann
----
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.