strptime

(PHP 5 >= 5.1.0, PHP 7)

strptime锟斤拷锟斤拷锟斤拷 strftime() 锟斤拷锟缴碉拷锟斤拷锟节o拷时锟斤拷

说锟斤拷

strptime ( string $date , string $format ) : array

strptime() 锟斤拷锟斤拷一锟斤拷锟斤拷 date 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷椋拷锟斤拷锟斤拷锟斤拷锟斤拷 FALSE锟斤拷

锟铰份猴拷锟斤拷锟节硷拷锟斤拷锟斤拷锟斤拷锟皆硷拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟叫关碉拷锟街凤拷锟斤拷锟斤拷应锟斤拷 setlocale()锟借定锟侥碉拷前锟斤拷锟斤拷LC_TIME锟斤拷锟斤拷

锟斤拷锟斤拷

date锟斤拷string锟斤拷

锟斤拷锟斤拷锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷锟斤拷锟� strftime() 锟斤拷锟截的o拷

format锟斤拷string锟斤拷

date 锟斤拷使锟矫的革拷式锟斤拷锟斤拷锟斤拷同 strftime() 锟斤拷锟斤拷使锟矫碉拷锟斤拷同锟斤拷锟斤拷

锟斤拷锟斤拷锟叫关革拷式选锟斤拷锟斤拷锟较拷锟� strftime() 页锟芥。

锟斤拷锟斤拷值

锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE

锟斤拷锟斤拷锟叫帮拷锟斤拷锟斤拷锟铰碉拷元
锟斤拷锟斤拷 说锟斤拷
tm_sec 锟斤拷前锟斤拷锟斤拷锟节碉拷锟斤拷锟斤拷锟斤拷0-61锟斤拷
tm_min 锟斤拷前小时锟节的凤拷锟斤拷锟斤拷锟斤拷0-59锟斤拷
tm_hour 锟斤拷夜锟斤拷锟叫∈憋拷锟斤拷锟�0-23锟斤拷
tm_mday 锟铰凤拷锟叫的第硷拷锟届(1-31锟斤拷
tm_mon 锟斤拷一锟斤拷锟斤拷锟斤拷思锟斤拷锟斤拷拢锟�0-11锟斤拷
tm_year 锟斤拷 1900 锟斤拷锟斤拷锟斤拷思锟斤拷锟�
tm_wday 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷思锟斤拷欤�0-6锟斤拷
tm_yday 锟斤拷锟斤拷锟斤拷一锟斤拷一锟斤拷锟斤拷锟斤拷硕锟斤拷锟斤拷欤�0-365锟斤拷
unparsed date 锟斤拷未锟斤拷通锟斤拷指锟斤拷锟斤拷 format 识锟斤拷牟锟斤拷锟�

锟斤拷锟斤拷

Example #1 strptime() 锟斤拷锟斤拷

<?php
$format 
'%d/%m/%Y %H:%M:%S';
$strf strftime($format);

echo 
"$strf\n";

print_r(strptime($strf$format));
?>

锟斤拷锟斤拷锟斤拷锟教碉拷锟斤拷锟斤拷锟斤拷锟斤拷冢锟�

03/10/2004 15:54:19

Array
(
    [tm_sec] => 19
    [tm_min] => 54
    [tm_hour] => 15
    [tm_mday] => 3
    [tm_mon] => 9
    [tm_year] => 104
    [tm_wday] => 0
    [tm_yday] => 276
    [unparsed] =>
)

注锟斤拷

Note: 锟剿猴拷锟斤拷未锟斤拷 Windows 平台锟斤拷实锟街★拷

Note:

Internally, this function calls the strptime() function provided by the system's C library. This function can exhibit noticeably different behaviour across different operating systems. The use of date_parse_from_format(), which does not suffer from these issues, is recommended on PHP 5.3.0 and later.

Note:

"tm_sec" includes any leap seconds (currently upto 2 a year). For more information on leap seconds, see the » Wikipedia article on leap seconds.

Note:

Prior to PHP 5.2.0, this function could return undefined behaviour. Notably, the "tm_sec", "tm_min" and "tm_hour" entries would return undefined values.

锟轿硷拷

  • checkdate() - 锟斤拷证一锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�
  • strftime() - 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟矫革拷式锟斤拷锟斤拷锟斤拷时锟戒/锟斤拷锟斤拷
  • date_parse_from_format() - Get info about given date formatted according to the specified format
  • DateTime::createFromFormat() - 锟斤拷锟捷革拷锟斤拷锟侥革拷式锟斤拷锟斤拷锟斤拷锟斤拷时锟斤拷锟街凤拷锟斤拷