Time functions commonly used in PHP

Source: Internet
Author: User
Tags time 0

Test environment: php5.3.29

The Unix timestamp (from the Unix era (January 1 1970 00:00:00 GMT) to the number of seconds in a given time. )。 hereinafter referred to as the timestamp.

Returns a time stamp for a time.

Time ();

Gets the timestamp of the current native time.

Mktime (hours, minutes, seconds, months, days, years);

From right to left can be omitted, omitted to the parameter is replaced with the local time, such as omitted the last day and year on the application of the current time of 22nd 2016 years.

Can write two-bit or four-digit numbers in a year. Two-digit time 0-69 corresponds to the 2000-2069,70-100 corresponding to 1970-2000. Four-bit-time test valid range 1970 to 2037.

Date (' y-m-d h:i ', $time);

Takes the timestamp of parameter 2 and obtains the string in the format of parameter 1. This is my most used format: 2016-08-22 09:02

Parameter 1 supports a number of alphabetic values, such as: s (seconds with leading zeros), M (three abbreviated months), Y (two-digit year), T (the local time zone), etc. go to the manual to find out.

GETDATE ($ time stamp);

Returns a Unix timestamp as an array, the default value for the current local time, and the return value format as follows

Array (    [seconds] = [    minutes] = [    hours] =   9//24 hour 9 points    [mday]    = 22//Date    [wday]    = 6//Monday 6    [mon]     = 10//October    [year]    [yday]    = 295// No. 295 Day of the Year    [weekday] = saturday//6    [month]   = october//October    [0]       = 1055901520// Time stamp)

Amount That's all I'm used to.

Time functions commonly used in PHP

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.