note 100144 added to function.strtotime
| From: | sam at frontiermedia dot net dot au | Date: | Tue, 28 Sep 2010 10:23:21 +0000 |
| Subject: | note 100144 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172760@lists.php.net to get a copy of this message | ||
I've had a little trouble with this function in the past because (as some people have pointed
out) you can't really set a locale for strtotime. If you're American, you see 11/12/10 and
think "12 December, 2010". If you're Australian (or European), you think it's 11
December, 2010. If you're a sysadmin who reads in ISO, it looks like 10th December 2011.
The best way to compensate for this is by modifying your joining characters. Forward slash (/)
signifies American M/D/Y formatting, a dash (-) signifies European D-M-Y and a period (.) signifies
ISO Y.M.D.
Observe:
echo date("jS F, Y", strtotime("11.12.10"));
// outputs 10th December, 2011
echo date("jS F, Y", strtotime("11/12/10"));
// outputs 12th November, 2010
echo date("jS F, Y", strtotime("11-12-10"));
// outputs 11th December, 2010
Hope this helps someone!
----
Server IP: 69.147.83.197
Probable Submitter: 58.165.135.198
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- https://master.php.net/note/edit/100144
Del: integrated -- https://master.php.net/note/delete/100144/integrated
Del: useless -- https://master.php.net/note/delete/100144/useless
Del: bad code -- https://master.php.net/note/delete/100144/bad+code
Del: spam -- https://master.php.net/note/delete/100144/spam
Del: non-english -- https://master.php.net/note/delete/100144/non-english
Del: in docs -- https://master.php.net/note/delete/100144/in+docs
Del: other reasons-- https://master.php.net/note/delete/100144
Reject -- https://master.php.net/note/reject/100144
Search -- https://master.php.net/manage/user-notes.php