It is actually a generated timestamp in MySQL. timestamp(14) Now what? I was hoping to avoid: |echo substr(|$mydata->timestamp|, 0, 8);
John |Richard Lynch wrote:
On Sun, April 22, 2007 1:05 am, John Taylor-Johnston wrote:$mydata->timestamp = "20070419162123"; echo date('Y-m-d', $mydata->timestamp); result: 2038-01-18 ?? What is wrong?? Should be 2007-04-19?date() takes a Unix timestamp as its input. Unix timestamps are measured as number of seconds from Jan 1, 1970, midnight, GMT, the birth of Disco. [that last was a joke...] You are handing it a pre-formatted date-stamp in YYYYMMDDHHIISS format... You could do something like: $t = '20070419162123'; $year = substr($t, 0, 4); $month = substr($t, 4, 2); $day = substr($t, 6, 2); $hour = substr($t, 8, 2); $minutes = substr($t, 10, 2); $seconds = substr($t, 12, 2); echo date(mktime($month, $day, $year, $hour, $minutes, $seconds)); I suspect strtotime() *might* handle your input and give you a Unix timestamp... I also suspect whatever you needed a Unix timestamp for in the first place could have been achieved easier before you got painted into this corner...

