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????? Quote Link to comment 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]; Quote Link to comment 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! 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.