簡體   English   中英

PHP strtotime功能評估

[英]PHP strtotime function assessment

我正在為一個較小的項目使用strtotime函數,它是一個非常強大的工具,但是我只需要一些幫助即可使用它。

當它自動評估給定日期時,有什么方法可以捕捉? 例如,當您輸入strtotime(“ 2/30/2006”)時,它將返回3/2/2006的時間戳。 或者,如果您在1970年之前放置任何日期,它將返回1970年1月1日的時間戳。

對於這些輸入,strtotime函數必須在做一些評估這些字符串的事情,我想知道是否有任何方法可以捕獲這些觸發器。

謝謝。

strtotime()函數將英語文本日期時間解析為Unix時間戳(自格林尼治標准時間1970年1月1日00:00:00起經過的秒數)。

注意:如果以兩位數字格式指定年份,則0-69之間的值將映射到2000-2069,而70-100之間的值將映射到1970-2000。

注意:注意日期格式為m / d / y或dmy; 如果分隔符為斜杠(/),則假定為美國m / d / y。 如果分隔符是破折號(-)或點(。),則采用歐洲dmy格式。 為避免潛在的錯誤,應盡可能使用YYYY-MM-DD日期或date_create_from_format()。

日期有明確的格式要輸入:

d - The day of the month (from 01 to 31)D - A textual representation of a day (three letters)j - The day of the month without leading zeros (1 to 31)l (lowercase 'L') - A full textual representation of a dayN - The ISO-8601 numeric representation of a day (1 for Monday, 7 for Sunday)S - The English ordinal suffix for the day of the month (2 characters st, nd, rd or th. Works well with j)w - A numeric representation of the day (0 for Sunday, 6 for Saturday)z - The day of the year (from 0 through 365)W - The ISO-8601 week number of year (weeks starting on Monday)F - A full textual representation of a month (January through December)m - A numeric representation of a month (from 01 to 12)M - A short textual representation of a month (three letters)n - A numeric representation of a month, without leading zeros (1 to 12)t - The number of days in the given monthL - Whether it's a leap year (1 if it is a leap year, 0 otherwise)o - The ISO-8601 year numberY - A four digit representation of a yeary - A two digit representation of a yeara - Lowercase am or pmA - Uppercase AM or PMB - Swatch Internet time (000 to 999)g - 12-hour format of an hour (1 to 12)G - 24-hour format of an hour (0 to 23)h - 12-hour format of an hour (01 to 12)H - 24-hour format of an hour (00 to 23)i - Minutes with leading zeros (00 to 59)s - Seconds, with leading zeros (00 to 59)u - Microseconds (added in PHP 5.2.2)e - The timezone identifier (Examples: UTC, GMT, Atlantic/Azores)I (capital i) - Whether the date is in daylights savings time (1 if Daylight Savings Time, 0 otherwise)O - Difference to Greenwich time (GMT) in hours (Example: +0100)P - Difference to Greenwich time (GMT) in hours:minutes (added in PHP 5.1.3)T - Timezone abbreviations (Examples: EST, MDT)Z - Timezone offset in seconds. The offset for timezones west of UTC is negative (-43200 to 50400)c - The ISO-8601 date (e.g. 2013-05-05T16:34:42+00:00)r - The RFC 2822 formatted date (e.g. Fri, 12 Apr 2013 12:01:05 +0200)U - The seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)

並且還可以使用以下預定義的常量(自PHP 5.1.0起可用):

DATE_ATOM-Atom(示例:2013-04-12T15:52:01 + 00:00)DATE_COOKIE-HTTP Cookies(示例:UTC 13年4月12日星期五15:52:01 UTC)DATE_ISO8601-ISO-8601(示例:2013 -04-12T15:52:01 + 0000)DATE_RFC822-RFC 822(例如:星期五,13 Apr 12 15:52:01 +0000)DATE_RFC850-RFC 850(例如:星期五,2013年4月12日15:52:01 UTC)DATE_RFC1036-RFC 1036(例如:Fri,12 Apr 13 15:52:01 +0000)DATE_RFC1123-RFC 1123(例如:Fri,12 Apr 2013 15:52:01 +0000)DATE_RFC2822-RFC 2822(Fri,12 2013年4月15:52:01 +0000)DATE_RFC3339-與DATE_ATOM(自PHP 5.1.3起)相同DATE_RSS-RSS(2013年8月12日星期五15:52:01 +0000)DATE_W3C-萬維網聯盟(例如2013- 04-12T15:52:01 + 00:00)

訪問此處獲取信息Php strtotime()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM