"Joshua Beall" <jbeall@donotspam.remove.me.heraldic.us> wrote in message
news:MxPhc.44294$L31.36599@nwrddc01.gnilink.net...[color=blue]
> Hi All,
>
> Any thoughts on the easiest way to translate a MySQL timestamp (which[/color]
looks[color=blue]
> like 20040422090941) to the datetime format (which looks like 2004-04-22
> 09:09:41). This is just to make it easier for a human to read it.
>
> I have thought about splitting it into chunks using something like
> str_split, then piecing it back together, but it seems like there should[/color]
be[color=blue]
> an easier way. And also, I am not running PHP5.
>
> I already tried date("Y-m-d H:i:s",strtotime("20040422090941")), and had[/color]
no[color=blue]
> luck. strtotime cannot handle that format.
>
> This seems like the sort of thing you should be able to do in 1 line of
> code. Any pointers?
>
> -Josh[/color]
Grabbed from
http://www.weberdev.com/get_example.php3/1427
function revertTimeStamp($timestamp)
{
$year=substr($timestamp,0,4);
$month=substr($timestamp,4,2);
$day=substr($timestamp,6,2);
$hour=substr($timestamp,8,2);
$minute=substr($timestamp,10,2);
$second=substr($timestamp,12,2);
$newdate=mktime($hour,$minute,$second,$month,$day, $year);
return($newdate);
}
--
Andrew @ Rockface
np: Günter Neuhold / Badische Staatskapelle - Erste Szene ; Hehe! Ihr
Nicker!
andrew@rockface-records.co.uk www.rockface-records.co.uk