Home  >  Article  >  Backend Development  >  PHP Date Knowledge_PHP Tutorial

PHP Date Knowledge_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:31:54827browse

(1)date
Usage: date(format,[time]);
If there is no time parameter, the current time is used. The format is a string, in which the following characters have special meanings:
U is replaced by the number of seconds since a starting time (like January 1, 1970)

Y is replaced with a 4-digit year number.
y is replaced with a 2-digit year number.
F is replaced with the full English name of the month.
M is replaced with the English abbreviation of the month.
m Replace with the number of months.
z Replace with the number of days since January 1 of the current year.
d Replace with the number of days.
l Replace with the full English name of the day of the week.
D Replace with the day of the week English abbreviation.
w is replaced with the day of the week (number).
H is replaced with the number of hours (24-hour format).
h is replaced with the number of hours (12-hour format).
i is replaced with minutes. Number.
s is replaced with seconds.
A is replaced with "AM" or "PM".
a is replaced with "am" or "pm".
S is replaced with ordinal suffix, for example :"st","nd","rd","th".

(2)PHP method to calculate the difference between two times

$date=floor((strtotime($enddate)-strtotime($startdate))/86400);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/760670.htmlTechArticle(1)date usage: date(format,[time]); If there is no time parameter, the current time is used . The format is a string in which the following characters have special meaning: U is replaced by starting from a starting time (well...
Statement:
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