Share on Google+Share on Google+

PHP Make Time

PHP Make Time tutorial discussed about the format, various parameter of make time function of PHP, it also includes an example which gives you an idea about make time function.

PHP  Make Time

In PHP, mktime() funtion is used for doing date arithmetic-calculation and validation.

The general format of mktime() is : 

int mktime ([ int $hr= date("H") [, int $min= date("i") [, int $sec= date("s") [, int $mon= date("n") [, int $day= date("j") [, int $yr= date("Y") [, int $is_dst= -1 ]]]]]]] )


hour The number of the hour
minute The number of the minute
second The number of the seconds
month The number of the month
day The number of the day
year The number of the year, may be a two or four digit value
is_dst This parameter is set to either of these values: 1 if the time is during Daylight Savings Time (DST), 0 if it is not, or -1 if it is unknown 

To calculate next day use the following code:



//To know previous date

$yesterday = mktime(0,0,0,date("m"),date("d")-1,date("Y"));

echo "<b>Yesterday was :</b>".date("d/m/Y", $yesterday);

echo "<br/>";

//To know next date 

//Where current date is: 10/10/2009

$tomorrow = mktime(0,0,0,date("m"),date("d")+1,date("Y"));

//Please note the difference between the date format given above and below

//To know the date format in detail please visit our web page

echo "<b>Tomorrow is :</b>".date("Y/m/d", $tomorrow);



Yesterday was :09/10/2009
Tomorrow is :2009/10/11



Posted on: October 10, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.