note 35346 added to function.date

From: Date: Thu, 28 Aug 2003 11:29:51 +0000
Subject: note 35346 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-55231@lists.php.net to get a copy of this message
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(). ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35346 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35346&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35346&report=yes

« previous php.notes (#55231) next »