OLG Posted July 20, 2007 Share Posted July 20, 2007 Hey guys, time for me to be the noob now (as if that ever changed ) How would i go about formatting a timestamp like this from my MYSQL DB: 20070720111445 Into something nice and coherent such as: 20th of July 2007 HH:MM Thank you, Adam Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 20, 2007 Share Posted July 20, 2007 You can either use the date() function. www.php.net/date Or you could use mysql's TIME_FORMAT function. http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html Quote Link to comment Share on other sites More sharing options...
gerkintrigg Posted July 20, 2007 Share Posted July 20, 2007 use date("d/m/Y",$timestamp); look up "date PHP" in google... it has great links there. the d, m and Y can all be changed depending on the way you want to display the stuff. hope it helps. Cheers Quote Link to comment Share on other sites More sharing options...
OLG Posted July 20, 2007 Author Share Posted July 20, 2007 Yes, i did know about the date format, but it keeps throwing out the wrong dates I don't think its 2038 quite yet Quote Link to comment Share on other sites More sharing options...
per1os Posted July 20, 2007 Share Posted July 20, 2007 Yes, i did know about the date format, but it keeps throwing out the wrong dates I don't think its 2038 quite yet What format is your timestamp in? Is it a unix timestamp? If not look into www.php.net/strtotime The issue lies within the timestamp, not the date function. Quote Link to comment Share on other sites More sharing options...
OLG Posted July 20, 2007 Author Share Posted July 20, 2007 I'm not actually sure, i've just changed over to a Plesk Server (8.1.1, using Virtuozzo, so i guess not) and am now having problems (its an older MYSQL Version) its arranged YYYYMMDDHHMMSS (Year, Month, Day, Hour, Minute, Seconds) strtotime returns -1, so i guess its telling me to go blow a fish right? I might just do a regular expression match, use some backreferences and re-organise it and just leave it like that, can't be assed to screw around with a timestamp. Quote Link to comment 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.