Hi,
When using strtotime(dd/mm/yyyy), php processes it as mm/dd/yyyy, how do I get it to process it the Australian way rather than the American way?
Hi,
When using strtotime(dd/mm/yyyy), php processes it as mm/dd/yyyy, how do I get it to process it the Australian way rather than the American way?
Take a look at the [man]date/man function.
How exactly do the Aussies format their dates?
You can split it out ([man]explode[/man] on /), then use [man]mktime[/man] or put it back together the american way...
Aussies format their date as dd/mm/yyyy as opposed to mm/dd/yyyy
Originally posted by LordShryku
You can split it out ([man]explode[/man] on /), then use [man]mktime[/man] or put it back together the american way...
There has to be an easier way to do it than that. I'm sure whoever it was that made PHP thought of us in the Land Downunder and our way of formatting dates.
// Original Formatted Date
$date = "09/21/2004";
// strtotime to convert to Unix Timestamp
$date = strtotime($date);
// Date function to convert to your desired format
$date = date("d/m/Y", $date);
echo $date;
// Outputs: 21/09/2004
Yes, that could work, except I have it in my database as dd/mm/yyyy.
Well, you should've used your DBMS's own date/time types to store dates Or at the very least use an unambiguous format, like some subset of ISO8601 (i.e., yyyy-mm-dd).
Consider strtotime('08/12/2004'). How is that date to be interpreted? 12th August or 8th December? The third alternative is to just give up and complain that it's unparseable, but strtotime was written by Americans.
If you don't want to use explode(), consider using sscanf().