PHP Date-format Date
The date () function in the first argument specifies how the date/time is formatted. It uses the letter-represented date and time format. Here are some letters that can be used to:
Buckle-one months of the day (January 3 1st)
M--The current one months, as a number (0 1-12)
Y-year in four digits
An overview of all the letters that can be used for format parameters can be found in our PHP date range.
Other characters, such as "/", ". "or"-"can also be inserted between the letters, add additional formatting:
<?php
echo Date ("y/m/d");
echo "<br/>";
echo Date ("Y.M.D");
echo "<br/>";
echo Date ("y-m-d");
? >
The output is as follows.
2006/07/11
2006.07.11
2006-07-11
PHP Date-add timestamp
the date () function in the second argument specifies a time stamp. This parameter is optional. If you do not provide a time, the current time will be used.
In our next example we will use the Mktime () function to create a time stamp tomorrow.
The Mktime () function returns a UNIX timestamp of a specific date.
Syntax
mktime (HOUR,MINUTE,SECOND,MONTH,DAY,YEAR,IS_DST)
Go to the future of the day, we just add one day argument mktime ():
<?php
$tomorrow = mktime (0,0,0,date ("M"), date ("D") +1,date ("Y")); echo "Tomorrow is". Date ("y/m/d", $tomorrow);
?
The
output is like.
tomorrow is 2006/07/12