I couldn't figure out how to do it using one of the existing PHP functions, so I wrote one.
/*
return value determined by $format which
defaults to unix timestamp. For formatted string
set to 's' when passing.
*/
function reformatTS($tstamp,$format="u"){
$unix_stamp = strtotime(substr($tstamp,0,4) . "-" .
substr($tstamp,4,2) . "-" .
substr($tstamp,6,2) . " " .
substr($tstamp,8,2) . ":" .
substr($tstamp,10,2) . ":" .
substr($tstamp,12,2));
if($format == "u"){
return($unix_stamp);
} else if($format == "s") {
return(strftime("%m-%d-%Y %H:%M:%S",$unix_stamp));
}
}//END function reformatTS
so when you need to format the date, call reformatTS. If you pass 's' as the second parameter it will format the date like this:
YYYY-MM-DD H:M:S
But if you want to use date or strftime to format it a different way, don't pass a second parameter and use the result returned as your int timestamp.
I only tested the function using a full 14 char timestamp field. If you have a different size, you may have to modify.