Re: Non American strtotime
| From: | Jon Bennett | Date: | Fri, 16 Jan 2004 12:04:31 +0000 |
| Subject: | Re: Non American strtotime | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-174779@lists.php.net to get a copy of this message | ||
try using this function to re-order UK to US dates and vice versa
// converts a UK date (DD-MM-YYY) to a US date (MM-DD-YYYY) and vice versa so strtotime doesn't fail
// expects a string such as "24/05/2004" or "05/24/2004"
function convertDate ($sDate) {
$aDate = split ("/", $sDate);
$return = $aDate[1]."/".$aDate[0]."/".$aDate[2];
return $return;} hth, Jon jon bennett | jon@jben.net new media creative _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ J b e n . n e t 91 Gloucester Rd, Trowbridge, Wilts, BA14 0AD t: +44 (0) 1225 341039 w: http://www.jben.net/ On 16 Jan 2004, at 11:13, Tom wrote:
Is there a way I can force PHP's time functions not to read date strings in the American MM-DD-YYYY format? I am using strtotime and strftime and date at various points (mainlty to avoid some niggly 0/NULL problems between PHP and mySQL and datefields). My date calculations (which are done in mySQL) are coming out with screwy results: adding 6 months the 3rd July becomes 7th September. ("03/07/2004" reads as 7th March, add six months for 7th September which is then displayed as "07/09/2003"). Is there a way I can have strtotime read "10-01-2004" (and all other such date connotations) as the 10th Jan and not 1st Oct? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php