phpretard Posted May 28, 2009 Share Posted May 28, 2009 I know this is probable an easy question but, What is the best way to display "2009-05-27 20:35:18" as this "05-27-2009"? Link to comment https://forums.phpfreaks.com/topic/159960-solved-reading-time/ Share on other sites More sharing options...
gizmola Posted May 28, 2009 Share Posted May 28, 2009 explode on the ' ' character. You'll get two strings -- the first one is the one you want. Link to comment https://forums.phpfreaks.com/topic/159960-solved-reading-time/#findComment-843724 Share on other sites More sharing options...
phpretard Posted May 28, 2009 Author Share Posted May 28, 2009 Exploding is something I am still working on (literally and metaphorically). Any pointers? Link to comment https://forums.phpfreaks.com/topic/159960-solved-reading-time/#findComment-843725 Share on other sites More sharing options...
phpretard Posted May 28, 2009 Author Share Posted May 28, 2009 I have it as "2009-05-27" no minutes or seconds I just need to rearrange a little Link to comment https://forums.phpfreaks.com/topic/159960-solved-reading-time/#findComment-843727 Share on other sites More sharing options...
PFMaBiSmAd Posted May 28, 2009 Share Posted May 28, 2009 If the original value is in a database, you can use the mysql DATE_FORMAT() function in your SELECT query to give you the date in any format you want. Link to comment https://forums.phpfreaks.com/topic/159960-solved-reading-time/#findComment-843730 Share on other sites More sharing options...
phpdragon Posted May 28, 2009 Share Posted May 28, 2009 $startdate="2009-05-27 20:35:18"; $predate=explode(' ', $startdate); $splitdate=explode('-', $predate[0]); $newdate="$splitdate[2]-$splitdate[1]-$splitdate[0]"; echo $newdate; Link to comment https://forums.phpfreaks.com/topic/159960-solved-reading-time/#findComment-843731 Share on other sites More sharing options...
Ken2k7 Posted May 28, 2009 Share Posted May 28, 2009 <?php $time = '2009-05-27 20:35:18'; $pieces = explode(' ', $time); echo $pieces[0]; Or in SQL SELECT DATE_FORMAT(`date_column`, '%Y-%m-%d') AS `date` Link to comment https://forums.phpfreaks.com/topic/159960-solved-reading-time/#findComment-843733 Share on other sites More sharing options...
phpdragon Posted May 28, 2009 Share Posted May 28, 2009 sorry with my result switch $splitdate[2] and $splitdate[1] around to have the way you first described Link to comment https://forums.phpfreaks.com/topic/159960-solved-reading-time/#findComment-843734 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.