vj5 Posted January 25, 2008 Share Posted January 25, 2008 I am having problem with date. I read php.net to get some answers but still not able to do.I want to convert from 20080108 to Friday, January 04, 2008. Can someone please help with that date function? Link to comment Share on other sites More sharing options...
jhecht Posted January 25, 2008 Share Posted January 25, 2008 Assuming all of your days are that format: $string = '20080108';$year = substr($string,0,4);$month= substr($string,4,2);$day = substr($string,6);//This last one doesn't require a third argument because we are going to the end of the string$timestamp = mktime(0,0,0,$month,$day,$year);echo date('l F d, Y',$timestamp); You should use the time() function to store your database date information. It saves you a few lines of code. Link to comment Share on other sites More sharing options...
vj5 Posted January 25, 2008 Author Share Posted January 25, 2008 Assuming all of your days are that format:$string = '20080108';$year = substr($string,0,4);$month= substr($string,4,2);$day = substr($string,6);//This last one doesn't require a third argument because we are going to the end of the string$timestamp = mktime(0,0,0,$month,$day,$year);echo date('l F d, Y',$timestamp); You should use the time() function to store your database date information. It saves you a few lines of code. Thank you for the code. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.