PHP Time function Strtotime use detailed

Source: Internet
Author: User
Tags echo date
This article is about the PHP time function strtotime Use of the detailed, has a certain reference value, now share to everyone, the need for friends can refer to

Definition and Usage strtotime ()
The strtotime () function resolves the datetime description of any English text to a Unix timestamp.

Grammar
Strtotime (Time,now)

parameters description /th>
Specifies the time string to parse.
now
    • Description
      The function expects to accept a string containing the U.S. English date format and attempts to resolve it to a Unix timestamp (the number of seconds from January 1 1970 00:00:00 GMT) whose value is relative to now The parameter gives the time, if this parameter is not provided, the current time of the system.
      The 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.

#1echo strtotime ("Now");  Gets the current timestamp echo date (' y-m-d h:i:s ', Strtotime ("Now"));//#2echo Strtotime ("2015-06-11 10:11:00");   Gets the specified timestamp echo date (' y-m-d h:i:s ', Strtotime ("2015-06-11 10:11:00")),//#3echo Strtotime ("3 October 2005"); Gets the specified timestamp [equivalent to Strtotime ("2005-10-03")]echo date (' y-m-d h:i:s ', Strtotime ("3 October 2005")),//#4echo strtotime ("+5 Hours ");   Current time plus five hours [comparison #1]echo date (' y-m-d h:i:s ', Strtotime ("+5 hours")),//#5echo Strtotime ("+1 Day");  Current time plus 1 days [comparison #1]echo date (' y-m-d h:i:s ', Strtotime ("+1 Day")),//#6echo strtotime ("+2 days"); The current time plus multi-day noun variable complex [contrast #1]echo date (' y-m-d h:i:s ', Strtotime ("+2 Days")),//#7echo strtotime ("+1 Week 3 days 7 hours 5 second S "); Current time plus 1 weeks 3 days 7 hours 5 seconds [Compare #1]echo date (' y-m-d h:i:s ', Strtotime ("+1 Week 3 day 7 hours 5 Seconds"));//#8echo Strtotime ("N  Ext Monday ");  Current time Next Monday echo date (' y-m-d h:i:s ', Strtotime ("Next Monday"));//#9echo Strtotime ("Last Sunday"); Current time before a Sunday echo date (' y-m-d h:i:s ', Strtotime ("Last Sunday"));//#10echo StRtotime ("-1 Day", Strtotime ("2018-07-01 10:11:00")); The given time minus one day echo date (' y-m-d h:i:s ', Strtotime ("-1 Days", Strtotime ("2018-07-01 10:11:00"));


time noun:
year of the plural years
month months plural months
Zhou Week plural weeks
daily day plural days
when hour complex hours
divided second plural seconds
seconds minute plural minutes
Previous Last
Next Next
January January
February February
March March
April April
May May
June June
July July
August August
September September
October October
November November
December December

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.