PHP operation time function strtotime () detailed

Source: Internet
Author: User
Tags echo date
PHP operation time function strtotime () detailed

The "time before printing" format conversion topic, is:

echo Date ("Y-m-d h:i:s", Strtotime ("1 day"));

"Print the first day of the last one months":

$a =mktime (0,0,0,date ("M") -1,1,date ("Y"));//Get UNIX values for the first day of next month
$next _mon_first_day=date ("y-m-d", $a);

Think of this strtotime() is quite magical, if you can use it flexibly, will certainly bring a lot of convenience to the work, but the PHP manual in the function of the parameters are not too much introduction, to some of the functions of the other introduction is very few. Organize the relevant information as follows:

First look at the manual introduction:

strtotime-to parse the datetime description of any English text into a Unix timestamp

Format: int strtotime (String $time [, int $now])

This function expects to accept a string containing the U.S. English date format and attempt to resolve it to a Unix timestamp (the number of seconds from January 1 1970 00:00:00 GMT) whose value is relative to the time given by the now parameter, if this parameter is not provided, the current time of the system.

This function uses the TZ environment variable, if any, to calculate the timestamp. Since PHP 5.1.0 There is an easier way to define a time zone for all date/time functions. This procedure is described in the Date_default_timezone_get function page.

Note: If the given year is a two-digit format, its value of 0-69 means that 2000-2069,70-100 represents 1970-2000.
Parameters
Time: parsed string, formatted according to the syntax of the gnu» date input format. Before PHP 5.0, there were no milliseconds allowed in time, but could be omitted from PHP 5.0.
Now: the timestamp used to calculate the return value, the default value is the current time (), or the timestamp of the other time.

return Value: Success returns the inter-stamp, otherwise false ( This function returns 1 in case of failure before PHP 5.1.0, and the subsequent version returns false).

The first parameter of Strtotime can be our common English time format, such as "2008-8-20" or "Ten September 2000" and so on. It can also be a time description based on the parameter now, such as "+1 Day" and so on.

The following is the list of available parameters in the latter way, where "current time" refers to the value of the second parameter now, which defaults to the current time of the strtotime.

  • 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.