Jump to content

date function


vj5
 Share

Recommended Posts

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...