PHP Common functions Time

Source: Internet
Author: User
Tags time and date

string Date(string format [, int timestamp])
The parameter format represents the way the time is formatted, possibly in the following way:
Description of formatting methods
y 4 digit year, Y is 2 digits, e.g. 99 is 1999
m Digit month, preceded by a leading 0, such as 01. N is no leading 0 digit month
F Month, full text format, such as January or March
M Three-letter abbreviation for the month, such as Jan or Mar
the day of the D-month preceded by a leading 0, such as 03. J is a number of days without leading 0
The day of the W week, expressed as a number, 0 means Sunday
The day ordinal of the Z-year, range 0-366
the first week of the W year, such as the 32nd week
H 24-hour format with leading 0,h for 12-hour format
G 24-hour format, no preamble 0,g for corresponding 12-hour format
i-minute format with leading 0
S-second format with leading 0
A Uppercase in the afternoon, such as am,a for lowercase
an optional parameter, timestamp, represents a timestamp, which defaults to time (), which is the current timestamp.
We can display the required time and date using the rich formatting provided by the date () function, as in the following example:
date ("Y-m-d", Time ()); Display format such as 2008-12-01
date ("Y.m.d", Time ()); Display format such as 2008.12.01
Date ("M D Y", Time ()); Display formats like Dec
date ("Y-m-d h:i", Time ()); Display formats such as 2008-12-01 12:01
Tips
If you output the time and the actual difference of 8 hours (assuming you use the Beijing time zone), please check the php.ini file, do the following settings:
Date.timezone = PRC
Mktime(Hour, minute, second, month, day, year) gets the timestamp from the date, returns the timestamp successfully, otherwise returns false.
Parameters can be omitted from right to left, and any omitted parameters are set to the current value of the cost date and time. and automatically calculates the correct value for the out-of-range input. The last day of any given month can be expressed as the "0" day of the next month, not 1 days.
Strtotime(String Time,[,int now]) converts any English text string representation of the date to a timestamp, which is the inverse of the date ().

PHP Common functions Time

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.