Home  >  Article  >  Backend Development  >  How to use date and time functions in PHP_PHP Tutorial

How to use date and time functions in PHP_PHP Tutorial

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

​ (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 the number of seconds since a starting time (like January 1, 1970)
Replace Y 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.
Replace D with 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:
[1] The year is between 1900 and 32767 (including 1900 and 32767);
[2]The month is between 1 and 12;
[3] 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 stipulates that the program must run to completion 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/445587.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