note 78988 added to function.strtotime
| From: | thalesjacobi at thalesjacobi dot net | Date: | Tue, 06 Nov 2007 09:50:21 +0000 |
| Subject: | note 78988 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132029@lists.php.net to get a copy of this message | ||
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 :
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:
$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.
----
Server IP: 194.145.210.4
Probable Submitter: 81.149.30.53
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- https://master.php.net/note/edit/78988
Del: integrated -- https://master.php.net/note/delete/78988/integrated
Del: useless -- https://master.php.net/note/delete/78988/useless
Del: bad code -- https://master.php.net/note/delete/78988/bad+code
Del: spam -- https://master.php.net/note/delete/78988/spam
Del: non-english -- https://master.php.net/note/delete/78988/non-english
Del: in docs -- https://master.php.net/note/delete/78988/in+docs
Del: other reasons-- https://master.php.net/note/delete/78988
Reject -- https://master.php.net/note/reject/78988
Search -- https://master.php.net/manage/user-notes.php