1) Date
Usage:
Date (format, [time]);
If there is no time argument, the current time is used.
A format is a string in which the following characters have special meaning:
U replaces the number of seconds since a start time (as if it were January 1, 1970)
Y replaces the 4-digit reign.
Y replaces the 2-digit reign.
F replaces the full name of the month in English.
M replaces the English abbreviation of the month.
M replaces the number of months.
Z replaces the number of days since January 1 of the year.
D replaces the number of own.
L REPLACE the English full name of the week.
D replaces the English abbreviation of the day of the week.
W replaces the Day of the Week (number).
H replaces the number of hours (24-hour system).
H replaces the number of hours (12-hour system).
I replace the number of minutes.
s replaces the number of seconds.
A Replace with "AM" or "PM".
A replace with "AM" or "PM".
S replaces the ordinal number suffix, for example: "St", "nd", "rd", "th".
function returns a format string that has been replaced.
(2) getdate (time)
Returns a hash table, each subscript is:
"Seconds"-number of seconds
"Minutes"--fractions
"Hours"--Number of hours
"Mday"--Number of days
"Mon"--Number of months
"Year"--the reign of the year
"Yday"--number of days since January 1
"Weekday"--day of the week, English full name
"Month"--month, full name in English
(3) Gmdate
Similar to date, but first converts time to Greenwich standard.
(4) Mktime
Usage:
Mktime (hours, fractions, seconds, months, days, years);
Returns a time value that can be used for other functions.
(5) Time
Usage:
Time ();
Returns the number of seconds since Horizon January 1, 1970.
(6) Microtime
Usage:
Microtime ();
Returns a string that is divided into two parts with a space, and the latter part equals time ()
Return value, 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 between 1900 and 32767 (including 1900 with 32767);
[2] The month between 1 to 12;
[3] The day is within the allowable number of days of the month (considering a leap year);
Returns the logic true.
(8) Set_time_limit
Usage:
Set_time_limit (number of seconds);
Specifies that the program must run at the end of a specified number of seconds from the time the sentence is run.
Timeout, the program is out of error.
Example 1. Mktime () example
Mktime () is useful for date calculations and validation, and it automatically calculates the correct values for input that goes out of range. For example, each row in the following example produces a string "jan-01-1998".
<?php
echo Date ("M-d-y", mktime (0, 0, 0, 12, 32, 1997));
echo Date ("M-d-y", mktime (0, 0, 0, 13, 1, 1997));
echo Date ("M-d-y", mktime (0, 0, 0, 1, 1, 1998));
echo Date ("M-d-y", mktime (0, 0, 0, 1, 1, 98));
?>
Example 2. The last day of next month
The last day of any given month can be expressed as the first "0" Day of the next month, not 1 days. The following two examples will produce a string "The last day in Feb is:29".
<?php
$lastday = mktime (0, 0, 0, 3, 0, 2000);
Echo strftime ("Last day in Feb:%d", $lastday);
$lastday = mktime (0, 0, 0, 4,-31, 2000);
Echo strftime ("Last day in Feb:%d", $lastday);
?>