Wednesday, 9 July 2014

The easy way to deal with dates in PHP

One of the good things that PHP versions 5.1 and above come with is the utility-


 date_default_timezone_set('timezone');

What it means is that whenever you will use the date() function, it will take as reference the "timezone" you specified.

For a list of timezones , click here.

Once this is done, call date() with the necessary formatting parameters, for example, the format accepted by MySQL i.e, yyyy-mm-dd .You get it by,
date('Y-m-d')


If you want to know what that means,click here .

With this procedure you are ready to use dates easily !!

No comments:

Post a Comment