How to use the date and time functions in PHP

Source: Internet
Author: User
(1) date
Usage:
Date (format, [time]);
If there is no time parameter, the current time is used.
The format is a string. The following characters have special meanings:
U is replaced by the number of seconds since the start time (like January 1, 1970).
Y is replaced with the 4-digit year number.
Y is replaced with the 2-digit year number.
F is replaced with the full name of the month.
M is replaced with the abbreviation of the month.
M is replaced with the monthly number of copies.
Z is replaced by the number of days since January 1 of the current year.
D. Replace it with the daily number.
L replace it with the full name of the day of the week.
D. Replace it with the abbreviation of the day of the week.
W is replaced with the day of the week (number ).
Replace H with the hour (in the 24-hour format ).
Replace h with the hour (in 12-hour format ).
Replace I with the number of minutes.
Replace s with the number of seconds.
A is replaced with "AM" or "PM ".
A is replaced with "am" or "pm ".
S is replaced with a sequential numeric suffix, for example, "st", "nd", "rd", "th ".
The function returns a formatted string that has been replaced.
(2) getdate (time)
Returns a hash table with the following subscripts:
"Seconds" -- seconds
"Minutes" -- score
"Hours" -- hours
"Mday" -- number of days
"Mon" -- number of months
"Year" -- year
"Yday" -- number of days since January 1, January 1
"Weekday"-the day of the week.
"Month" -- month, full English name
(3) gmdate
Similar to date, but converts Time to Greenwich Mean Time first.
(4) mktime
Usage:
Mktime (hours, scores, seconds, months, days, and years );
Returns a time value for other functions.
(5) time
Usage:
Time ();
Returns the number of seconds since January 1, January 1, 1970.
(6) microtime
Usage:
Microtime ();
Returns a string, which is divided into two parts by space. The latter part is equivalent to time ()
The first part is the number of microseconds.
(7) checkdate
Usage:
Checkdate (month, day, year );
Returns logical truth 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 permitted number of days of the month (considering the leap year );
Returns the logical truth.
(8) set_time_limit
Usage:
Set_time_limit (seconds );
It is required that the program must end in the specified number of seconds from the time of running the sentence,
The program exits after timeout.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.