rlelek Posted March 24, 2008 Share Posted March 24, 2008 Anyone have any idea why this keeps returning the wrong date? function mysql_date_to_human($dt) { $yr=strval(substr($dt,0,4)); $mo=strval(substr($dt,5,2)); $da=strval(substr($dt,8,2)); return date("d/m/Y", mktime (0,0,0,$da,$mo,$yr)); } Example.... if the database column reads "2006-06-20" it will output "06/08/2007" when the function is called. Thanks for your help! Link to comment https://forums.phpfreaks.com/topic/97711-mysql-date-to-human-gone-wild/ Share on other sites More sharing options...
darkfreaks Posted March 24, 2008 Share Posted March 24, 2008 <?php return date("Y/m/d", mktime (0,0,0,$da,$mo,$yr)); ?> Link to comment https://forums.phpfreaks.com/topic/97711-mysql-date-to-human-gone-wild/#findComment-499973 Share on other sites More sharing options...
cooldude832 Posted March 25, 2008 Share Posted March 25, 2008 easier <?php mysql_date_to_human($date){ return date("d/m/y", strtotime($date)); } ?> Link to comment https://forums.phpfreaks.com/topic/97711-mysql-date-to-human-gone-wild/#findComment-499980 Share on other sites More sharing options...
rlelek Posted March 25, 2008 Author Share Posted March 25, 2008 Thanks a Bunch Wonderful help Quick Response Go PHPFreaks Link to comment https://forums.phpfreaks.com/topic/97711-mysql-date-to-human-gone-wild/#findComment-499987 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.