papaface Posted February 24, 2007 Share Posted February 24, 2007 Hello, I know this is simple, but ive forgotten how to do it. How do I convert a date from mysql like "2007-02-24 03:58:08" into "03:58:08" ? Thanks Link to comment https://forums.phpfreaks.com/topic/39937-solved-basic-datetime-question/ Share on other sites More sharing options...
paul2463 Posted February 24, 2007 Share Posted February 24, 2007 if you mean you only want to pull the time part from the database then select DATE_FORMAT(dbdate, '%H:%i:%s'); //outputs 03:58:08 from the database entry 2007-02-24 03:58:08 Link to comment https://forums.phpfreaks.com/topic/39937-solved-basic-datetime-question/#findComment-193048 Share on other sites More sharing options...
papaface Posted February 24, 2007 Author Share Posted February 24, 2007 where would I put that? Currently my data is taken from the db like this: $selectposts = mysql_query("select posts_name,posts_content,submitted_date from posts where shoutboxes_unique_id='{$_id}' order by submitted_date desc LIMIT $_start, $_limit"); submitted_date is the date i want to format Link to comment https://forums.phpfreaks.com/topic/39937-solved-basic-datetime-question/#findComment-193096 Share on other sites More sharing options...
paul2463 Posted February 24, 2007 Share Posted February 24, 2007 $selectposts = mysql_query("select posts_name,posts_content,DATE_FORMAT(submitted_date,'%H:%i:%s') AS fdate from posts where shoutboxes_unique_id='{$_id}' order by submitted_date desc LIMIT $_start, $_limit"); //the $row['fdate'] would be the formatted date Link to comment https://forums.phpfreaks.com/topic/39937-solved-basic-datetime-question/#findComment-193103 Share on other sites More sharing options...
papaface Posted February 24, 2007 Author Share Posted February 24, 2007 Thanks, works perfectly. Link to comment https://forums.phpfreaks.com/topic/39937-solved-basic-datetime-question/#findComment-193113 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.