PHP Strtotime Function Detailed description

Source: Internet
Author: User
This article describes the use of the timestamp function strtotime () in PHP and the need for a friend to refer to below.

Strtotime function is a very good function, flexible use of it, will give you a lot of convenience in the work. But the PHP manual does not introduce much of this function's parameters, and there are very few other descriptions of the functions. First look at the manual: strtotime-the datetime description of any English text to the 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 resolves 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.

The argument time is parsed by the string, formatted according to GNU? The syntax for the date input format. Before PHP 5.0, there were no milliseconds allowed in time, but could be omitted from PHP 5.0. Now is used to calculate the timestamp of the return value. The default value of this parameter is the current time (), or it can be set to a time stamp of another time (I have been ignoring a feature ah, ashamed) return value: Success returns a timestamp, otherwise FALSE. Before PHP 5.1.0, this function returns 1 on failure, and later 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 for the latter, where the "current time" refers to the value of the second parameter now of Strtotime, which defaults to the current time of 1. Month, day English name and its common abbreviation list: January,february,march,april,may,june, July,august,september,sept,october,november,december,sunday,monday,tuesday,tues,wednesday,wednes,thursday,thur , Thurs,friday,saturday

2. Time parameter Hexiang Description: am:the is before noon morning Pm:the is noon or later PM Year:one year; For example, the "next year", such as "next year", represents the next Month:one month; For example, ' last month ', for example, the previous months fortnight:two weeks; For example, "a fortnight ago" two weeks, such as "a fortnight ago" represents two weeks ago Week:one Week Week Day:a day Hour:an hour hours minute:a minute min Clock min:same as minute with "minute" second:a second seconds Sec:same as second with "second"

3. Correlation and Sequence Description: +n/-n: In the current time, add a minus the specified time, such as "+1 hour" refers to the current time plus an hour ago:time relative to now; such as "hours ago" in the current time, such as "hours Ago" represents "24 hours ago" tomorrow:24 hours later than the current date and time Date and time) as the standard, tomorrow at the same time yesterday:24 hours earlier than the current date and time as the standard, at the same time yesterday, today:the present D The current time of ate and time (including dates and times) now:the current date and time (including date and time) last:modifier meaning "the preceding"; For example, "Last Tuesday" stands for "previous", for example "last Tuesday" stands for "on Tuesday same time" this:the given time during the current day or the next OC Currence of the given time; For example, ' This 7am ' gives the timestamp for the ' the ', ' the ' This week ' gives the timestamp for one we The time stamp of the specified time of the day of the current time or the following period, such as "This 7am" gives the time stamp of the day 7:00, and "This week" gives the timestamp of the whole week starting from the present time, That is, the current time (tested by myself: Strtotime (' this Week ') =strtotime (' Now ')); next:modifier meaning the present value of the subject plus One For example, the current time of "next hour" plus the specified time, such as "next hour" means the current time plus an hour,Add 3600

//First come to this, in order to be not translated first:ordinal modifier, esp. for months; For example, "may first" (actually, it's just the same as next) t Hird:see First (note that there was no "second" for ordinality, since this would conflict with the second time value) four Th:see firstfifth:see firstsixth:see firstseventh:see firsteighth:see firstninth:see firsttenth:see Firstele Venth:see Firsttwelfth:see First

4. Time Zone Description: Gmt:greenwich Mean timeut:coordinated Universal timeutc:same as Utwet:western European timebst:british Su Mmer timewat:west Africa timeat:azores timeast:atlantic standard timeadt:atlantic daylight Timeest:eastern Stand ARD Timeedt:eastern Daylight timecst:central standard timecdt:central daylight timemst:mountain standard TIMEMDT: Mountain Daylight timepst:pacific standard timepdt:pacific daylight Timeyst:yukon standard Timeydt:yukon daylight Timehst:hawaii standard Timehdt:hawaii daylight timecat:central Alaska Timeakst:alaska Standard Timeakdt:alaska Daylight Timeahst:alaska-hawaii Standard Timent:nome timeidlw:international Date line westcet:central European Ti Memet:middle European timemewt:middle European Winter timemest:middle European Summer timemesz:middle European Sum Mer timeswt:swedish Winter timesst:swedish Summer timefwt:french Winter timefst:french Summer timeeet:eastern Eu Rope time, USSR Zone 1BT : Baghdad time, USSR zone 2ZP4:USSR zone 3ZP5:USSR zone 4ZP6:USSR Zone 5wast:west Australian Standard Timewadt: West Australian daylight Timecct:china Coast time, USSR zone 7jst:japan Standard Time, USSR zone 8east:eastern austr Alian Standard Timeeadt:eastern Australian daylight Timegst:guam Standard Time, USSR Zone 9nzt:new Zealand timenzst : New Zealand Standard timenzdt:new Zealand daylight timeidle:international Date line East

Specific application examples are included. See also article: PHP strtotime () function Usage Example

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