fantic Posted October 21, 2008 Share Posted October 21, 2008 in my database the date format is YYYY-MM-DD i want do display this format like "Monday, October 20, 2008". what is the solution? Link to comment https://forums.phpfreaks.com/topic/129384-convert-date-format/ Share on other sites More sharing options...
JasonLewis Posted October 21, 2008 Share Posted October 21, 2008 You need two functions. date() strtotime() strtotime() is used as the second argument in the date() function. Link to comment https://forums.phpfreaks.com/topic/129384-convert-date-format/#findComment-670734 Share on other sites More sharing options...
fantic Posted October 21, 2008 Author Share Posted October 21, 2008 i used date("r", strtotime($timestamp)); but it shows time also but i dont need time. Link to comment https://forums.phpfreaks.com/topic/129384-convert-date-format/#findComment-670738 Share on other sites More sharing options...
JasonLewis Posted October 21, 2008 Share Posted October 21, 2008 Look at the date() function in the manual. It gives you all the values you would need. $date = "2008-10-21"; echo date("l, F j, Y", strtotime($date)); //Will echo: Tuesday, October 21, 2008 Link to comment https://forums.phpfreaks.com/topic/129384-convert-date-format/#findComment-670740 Share on other sites More sharing options...
discomatt Posted October 21, 2008 Share Posted October 21, 2008 The ideal way to do this is to covert it directly in the database. With MySQL you'd use SELECT DATE_FORMAT(`dateCol`, '%W, %M %e, %Y') FROM `table` Link to comment https://forums.phpfreaks.com/topic/129384-convert-date-format/#findComment-670873 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.