note 35346 deleted from function.date by sniper
| From: | sniper@php.net | Date: | Sat, 11 Oct 2003 16:55:27 +0000 |
| Subject: | note 35346 deleted from function.date by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58303@lists.php.net to get a copy of this message | ||
Note Submitter: c.hester@ukonline.co.uk
----
A quick way to convert a date in UK format to US date format, so it can be converted into a UNIX
timestamp, is to simply reverse the day and month.
Example:
date given = "19/12/01" (UK date for 19th December 2001)
list ($day, $month, $year) = split ("/", "19/12/01");
$newdate = $month."/".$day."/".$year;
$unixdate = strtotime ($newdate);
$ukdate = date("d/m/y", $unixdate);
This splits the UK date into chunks then rearranges the first 2 to make it a US style date. Then it
gets the UNIX timestamp ready for further processing.
To convert back to a UK date format use the last line of code above. Note how you can use the slash
symbol with date().