Sort out common PHP time functions and php function documents

Source: Internet
Author: User

Sort out common PHP time functions and php function documents

Common time functions of php

Test environment: php5.3.29

Unix timestamp (the number of seconds from the Unix epoch (January 1 1970 00:00:00 GMT) to the given time .). The timestamp.

Returns the timestamp at a time.

Time ();

Obtains the timestamp of the current local time.

Mktime (hour, minute, second, month, day, year );

// The parameter can be omitted from the right to the left. The omitted parameter is replaced by the local time. For example, if the last day and the year are omitted, the current time is applied on January 22, 2016.

// Two or four digits can be written every year. When two digits are used, 0-69 corresponds to 2000-2069,70-100 corresponds to 1970-2000. The validity period of the four-digit test ranges from 1970 to 2037.

Date ('Y-m-d H: I ', $ time );

// Obtain the timestamp of parameter 2 in the format of parameter 1. This is my most commonly used format:

// Parameter 1 supports many other letter values, such as s (s with leading zeros), M (month with three abbreviations), and y (year with two digits), T (the time zone of the Local Machine), and so on.

Getdate ($ timestamp );

// Returns a unix timestamp in an array. The default value is the current local time. The returned format is as follows:

Array ([seconds] => 40 [minutes] => 58 [hours] => 9 // [mday] => 22 // Date [wday] => 6 // week 6 [mon] => 10 // October [year] => 2016 [yday] => 295 // 295th days of this year [weekday] => Saturday // 6 6 [month] => October // October [0] => 1055901520 // timestamp)

Thank you for reading this article. I hope it will help you. Thank you for your support for this site!

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.