Home  >  Article  >  Backend Development  >  Time function_PHP tutorial

Time function_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 10:59:52809browse

​ There are so many time functions in PHP:
(1)date
Usage:
date(format,[time]);
If there is no time parameter, the current time is used. The format is a string where the following characters have special meaning:
U is replaced with the number of seconds since a starting time (like January 1, 1970) and Y is replaced with the 4-digit year number.
Replace y with the 2-digit year number.
Replace F with the full English name of the month.
M is replaced with the English abbreviation of the month.
m is replaced by the number of months.
Replace z with the number of days since January 1st of the current year.
d is replaced by the number of days.
l Replace with the full English name of the day of the week.
D is replaced by the English abbreviation of the day of the week.
w is replaced by the day of the week (number).
H is replaced by the number of hours (24-hour format).
h is replaced by the number of hours (12-hour format).
Replace i with minutes.
Replace s with seconds.
Replace A with "AM" or "PM".
Replace a with "am" or "pm".
Replace S with an ordinal suffix, such as: "st", "nd", "rd", "th".
The function returns the replaced format string.

(2)getdate(time)
Returns a hash table, each subscript is:
"seconds" -- number of seconds
"minutes" -- Score
"hours" -- number of hours
"mday" -- day number
"mon" -- number of months
"year" -- year number
"yday" -- the number of days since January 1
"weekday" -- day of the week, full English name
"month" -- month, full English name

(3)gmdate
Similar to date, but first convert the time to Greenwich Mean Time.

(4)mktime
Usage:
mktime(hours, minutes, seconds, months, days, years); returns a time value that can be used in other functions.

(5)time
Usage:
time(); returns the number of seconds since midnight on January 1, 1970.

(6)microtime
Usage:
microtime(); returns a string, divided into two parts with spaces, the latter part is equivalent to time()
The return value of , the first part is the number of microseconds.

(7)checkdate
Usage:
checkdate(month, day, year); Returns logical true or logical false. If:
The year is between 1900 and 32767 (inclusive);
The month is between 1 and 12;
The day is within the allowed number of days in the month (leap years are taken into account);
then returns logical true.

(8)set_time_limit
Usage:
set_time_limit(seconds);
It is stipulated that the program must be completed within the specified number of seconds from the time this sentence is run. If the timeout occurs, the program will exit with an error.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445571.htmlTechArticleThe time functions in PHP are as follows: (1) date usage: date (format, [time]); If there is no time parameter, the current time is used. The format is a string where the following characters have special meaning: ...
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