The study of PHP time function

Source: Internet
Author: User

Hand-drawn a graph to summarize the processing function of time in PHP

The first timestamp is a string of numbers such as "1441202665", although people seem to be in trouble, but the computer can easily identify such a time representation.

So the time it takes to see the computer is a timestamp, which gives the person the "2015-09-02 22:25:30" string.

Time () Gets the current timestamp, the return type is int

Microtime () returns a string that consists of the current time's subtle number and timestamp, and returns the subtle number as the fractional part of the float if there is true as a parameter

Mktime (Hour,minute,second,month,day,year) converts the time represented by the parameter to a timestamp and returns. Note the parameter order

Strtotime () Converts a string into a timestamp and returns, as

Strtotime ("Now-1 Day"); The timestamp at this time yesterday

Strtotime ("Now +1 Day"); The time stamp for tomorrow.

In addition to day, you can also use week, month

Strtotime ("2015-09-02"); time stamp of//2015-09-02 00:00:00

Strtotime ("2015-09-02 22:39:30"); Returns the timestamp of the 2015-09-02 22:39:30

Here are a few other examples:

Strtotime ("2015/09/02 22:39:30");

Strtotime ("20150902 22:39:30");

Strtotime ("20150902 223930");

Strtotime ("20150902223930");

The above form returns the same result

Basically, as long as you carefully write the normal time format string, the Strtotime can be turned into timestamps.

The study of PHP time function

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.