Summary of how to use the Date() time and date function in PHP_PHP Tutorial

WBOY
Release: 2016-07-21 15:31:04
Original
938 people have browsed it

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 how 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);
The format of each parameter is respectively:
a - "am" or "pm"
a - "am" or "pm"
d - Day, two digits, if there are less than two digits, add zeros in front; For example: "01" to "31"
d - Day of the week, three English letters; For example: "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, do not add zeros if there are less than two digits; such as: "1" to 12"
g - hour in 24-hour format, do not add zeros if there are less than two digits; such as: "0 " to "23"
i - minutes; such as: "00" to "59"
j - days, two digits, no zeros if less than two digits; 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; For example: "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 - day of the year; such as: "0" to "365"
Other characters not listed above Then list the character directly

php date - format date
The first parameter of the date() function specifies how to format the date/time, which uses letters to represent it. Date and time format. Here is a list of available letters:
d - day of month (01-31)
m - current month as a number (01-12)
y - current year (four digits) Number)
You can find all the letters that can be used in the format parameter in our php date reference manual.
You can insert other characters between letters, such as "/", "." or "-", so that you can add additional formatting:

Copy code The code is as follows:

echo date("y/m/d");
echo "
";
echo date("y.m.d");
echo "
";
echo date("y-m-d");
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323106.htmlTechArticleSyntax date(format,timestamp) Parameter Description format required. Specifies the format of the timestamp. timestamp is optional. Specify timestamp. The default is the current date and time. To find out the time of the previous day...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template