On Sunday 22 April 2007 08:33, John Taylor-Johnston wrote: > It is actually a generated timestamp in MySQL. > timestamp(14) Well, then just use the query to decide how it should look like. Mysql timestamp is amazingly easy to work with. whatevertable,date_format(timestamp_table, 'what should it look like') as timestamp or use another name if you need both like I do. > > 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... -- --- Børge http://www.arivene.net --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php