Thursday, November 10, 2011

php Date

PHP date() function formats a timestamp to a more readable date and time.
date(format,timestamp)


ParameterDescription
formatRequired. Specifies the format of the timestamp
timestampOptional. Specifies a timestamp. Default is the current date and time

<?php
echo date("Y/m/d") . "<br />";             //2009/05/11
echo date("Y.m.d") . "<br />";             //2009.05.11
echo date("Y-m-d");                        //2009-05-11
?>


mktime()
mktime() function returns the Unix timestamp for a date.


mktime(hour,minute,second,month,day,year,is_dst)
--------------------------------------
<?php
$tomorrow = mktime(0,0,0,date("m"),date("d")+1,date("Y"));
echo "Tomorrow is ".date("Y/m/d", $tomorrow);
?>


outputs tomorrow's date in format y/m/d
--------------------------------------

No comments:

Post a Comment