Syntax
date(format, timestamp) Parameter Description
format Required. Specifies the format of the timestamp.
timestamp optional. Specify timestamp. The default is the current date and time
To find the time of the previous day, use time()-60*60*24;
To find the time of the previous year, use time()*60*60*24*365
So what? To change this number into date format, you need to use the date() function
$t=time();www.3ppt.com
echo date("y-m-d h:i:s" ,$t);
Every The format of a parameter respectively represents:
a - "am" or "pm"
a - "am" or "pm"
d - day, two digits, if there are less than two digits, zero will be added in front; such as: "01" to "31"
d - day of the week, three English letters; such as: "fri"
f - month, full English name; such as: "january"
h - hour in 12-hour format; such as: "01 " to "12"
h - hour in 24-hour format; such as: "00" to "23"
g - hour in 12-hour format, no zeros are added for less than two digits; such as: "1" to 12"
g - Hours in 24-hour format, do not add zero if there are less than two digits; such as: "0" to "23"
i - minutes; such as: "00" to "59"
j - days, two digits, if there are less than two digits Do not add zeros; such as: "1" to "31"
l - day of the week, full English name; such as: "friday"
m - month, two digits, if there are less than two digits, add zeros in front; such as: " 01" to "12"
n - month, two digits, if there are less than two digits, no zero will be added; such as: "1" to "12"
m - month, three English letters; such as: "jan"
s - seconds; such as: "00" to "59"
s - add an English ordinal number at the end of the word, two English letters; such as: "th", "nd"
t - specify the number of days in the month; such as: "28" to" 31"
u - total seconds
w - numeric day of the week, such as: "0" (Sunday) to "6" (Saturday)
y - year, four digits; such as: "1999"
y - year , two digits; such as: "99"
z - the day of the year; such as: "0" to "365"
Other characters not listed above will be listed directly
php date - format date The first parameter of the
date() function specifies how to format the date/time. It uses letters to represent the date and time format. Here are some available letters:
d - Day of the month (01-31). )
m - the current month as a number (01-12)
y - the current year (four digits)
You can find all the letters that can be used in the format parameters in our php date reference manual.
You can insert other characters between letters, such as "/", "." or "-", so that you can add additional formatting:
Copy the code The code is as follows:
echo date("y/m/d");
echo "
";
echo date("y.m.d");
echo "
";
echo date("y-m-d" );
?>
The above introduces how to use truecrypt and a summary of how to use the Date function in PHP, including the use of truecrypt. I hope it will be helpful to friends who are interested in PHP tutorials.