hinch
08-07-2008, 01:02 PM
This isn't very big but I know alot of people around the place have looked for it similar (a quick google search proves this).
Basically its a simple function to take the mysql datetime field value and convert it into something a little more readable.
accepts date in format yyyy-mm-dd hh:mm:ss returns date in format dd-mm-yyyy hh:mm:ss
// convert dates FROM mysql format to UK format
function mysql2uk($date) {
$mainsplit = explode(" ",$date);
//$mainsplit[0]=date $mainsplit[1]=time
$datesplit = explode("-",$mainsplit[0]);
$newdate=$datesplit[2]."-".$datesplit[1]."-".$datesplit[0]." ".$mainsplit[1];
return $newdate;
}
Call it by using eg:
echo mysql2uk($date);
I know alot of you long time coders may find this useful but i'm fairly sure someone will use it at some point
Basically its a simple function to take the mysql datetime field value and convert it into something a little more readable.
accepts date in format yyyy-mm-dd hh:mm:ss returns date in format dd-mm-yyyy hh:mm:ss
// convert dates FROM mysql format to UK format
function mysql2uk($date) {
$mainsplit = explode(" ",$date);
//$mainsplit[0]=date $mainsplit[1]=time
$datesplit = explode("-",$mainsplit[0]);
$newdate=$datesplit[2]."-".$datesplit[1]."-".$datesplit[0]." ".$mainsplit[1];
return $newdate;
}
Call it by using eg:
echo mysql2uk($date);
I know alot of you long time coders may find this useful but i'm fairly sure someone will use it at some point