rsquaredpgh Posted June 14, 2010 Share Posted June 14, 2010 I've inherited a project on server a MySql 4.0 database running php 4.3. The problem is the timestamp info is stored as yyyymmddhhmmss. I need to echo this as a readable timestamp. i.e. (June 14th, 2010 06:29:21) etc. Is this possible? On the forums I've read it seems that in Mysql 4.1 is where the timestamp improved drastically. Does anyone know how to code this? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/204785-format-date-string-yyyymmddhhmmss/ Share on other sites More sharing options...
Psycho Posted June 14, 2010 Share Posted June 14, 2010 $timestamp = '20100614062921'; echo date('F jS, Y h:i:s', strtotime($timestamp)); //Output: June 14th, 2010 06:29:21 Quote Link to comment https://forums.phpfreaks.com/topic/204785-format-date-string-yyyymmddhhmmss/#findComment-1072130 Share on other sites More sharing options...
rsquaredpgh Posted June 15, 2010 Author Share Posted June 15, 2010 Thanks. I tried that and in place of the date I get the following error displayed on the page: Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in D:\root\username\domain\www\index.php on line 256 Not really sure what to do now. Quote Link to comment https://forums.phpfreaks.com/topic/204785-format-date-string-yyyymmddhhmmss/#findComment-1072220 Share on other sites More sharing options...
kenrbnsn Posted June 15, 2010 Share Posted June 15, 2010 What is your input string? Ken Quote Link to comment https://forums.phpfreaks.com/topic/204785-format-date-string-yyyymmddhhmmss/#findComment-1072223 Share on other sites More sharing options...
PFMaBiSmAd Posted June 15, 2010 Share Posted June 15, 2010 Your php version is too far out of date (as of php5.1, date() works back to Fri, 13 Dec 1901 20:45:54 GMT.) The end of life and support of php4 was over two years ago. Your mysql version is way out of date as well. Quote Link to comment https://forums.phpfreaks.com/topic/204785-format-date-string-yyyymmddhhmmss/#findComment-1072224 Share on other sites More sharing options...
rsquaredpgh Posted June 15, 2010 Author Share Posted June 15, 2010 Like I said ... I inherited the project. I've been in touch with the server admin about migrating the files to a server with updated versions. Until then, I'm just trying to make it work. What do you mean by input string, Ken? Which code piece are you referring to? Quote Link to comment https://forums.phpfreaks.com/topic/204785-format-date-string-yyyymmddhhmmss/#findComment-1072226 Share on other sites More sharing options...
PFMaBiSmAd Posted June 15, 2010 Share Posted June 15, 2010 The YYYYMMDDHHMMSS format should be recognized as a datetime value. What does the following produce - SELECT DATE_FORMAT('20100614062921', '%M %D, %Y %H:%i:%S'); Quote Link to comment https://forums.phpfreaks.com/topic/204785-format-date-string-yyyymmddhhmmss/#findComment-1072229 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.