note 78988 deleted from function.strtotime by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 08:00:58 +0000 |
| Subject: | note 78988 deleted from function.strtotime by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196724@lists.php.net to get a copy of this message | ||
Note Submitter: thalesjacobi at thalesjacobi dot net
----
strtotime() reads the timestamp in en_US format if you want to change the date format with this
number, you should previously know the format of the date you are trying to parse. Let's say
you want to do this :
<?php strftime("%Y-%m-%d",strtotime("05/11/2007")); ?>
It will understand the date as 11th of may 2007, and not 5th of november 2007. In this case I would
use:
<?php
$date = explode("/","05/11/2007");
strftime("%Y-%m-%d",mktime(0,0,0,$date[1],$date[0],$date[2]));
?>
Much reliable but you must know the date format before. You can use javascript to mask the date
field and, if you have a calendar in your page, everything is done.
Thank you.