timlondon Posted August 6, 2007 Share Posted August 6, 2007 If I fetch a date from a mysql field and the date is: 2006-01-12 00:00:00 Is there a way I can reformat it in php to lose the hr.min.sec so that I am just left with the date 2006-01-12????? Link to comment https://forums.phpfreaks.com/topic/63555-solved-changing-date-format/ Share on other sites More sharing options...
calabiyau Posted August 6, 2007 Share Posted August 6, 2007 I'm sure there's a way to only select the information you want from your query, but you could just explode the retrieved date by the space character and refer to the first item in the resulting array. $date_array = explode(' ',$old_date) $date_only = $date_array[0]; Link to comment https://forums.phpfreaks.com/topic/63555-solved-changing-date-format/#findComment-316724 Share on other sites More sharing options...
tmyonline Posted August 6, 2007 Share Posted August 6, 2007 Yes, if you select the date column from your MySQL database, do this: DATE_FORMAT(date, '%b %e, %Y') AS date It will format your date from YYYY-MM-DD to MM-DD-YYYY and it will cut off the hour.minute.second part. Good luck! Link to comment https://forums.phpfreaks.com/topic/63555-solved-changing-date-format/#findComment-316730 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.