PHP date() function formats a timestamp to a more readable date and time.
date(format,timestamp)
<?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
--------------------------------------
date(format,timestamp)
| Parameter | Description |
|---|---|
| format | Required. Specifies the format of the timestamp |
| timestamp | Optional. 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