strftime

(PHP 4, PHP 5, PHP 7)

strftime锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟矫革拷式锟斤拷锟斤拷锟斤拷时锟戒/锟斤拷锟斤拷

说锟斤拷

strftime ( string $format [, int $timestamp = time() ] ) : string

锟斤拷锟斤拷锟矫革拷锟斤拷锟侥革拷式锟街达拷锟皆革拷锟斤拷锟斤拷 timestamp 锟斤拷锟叫革拷式锟斤拷锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷锟矫伙拷懈锟斤拷锟绞憋拷锟斤拷锟斤拷锟矫碉拷前锟侥憋拷锟斤拷时锟戒。锟铰份猴拷锟斤拷锟节硷拷锟皆硷拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟叫关碉拷锟街凤拷锟斤拷写锟斤拷锟斤拷锟斤拷 setlocale() 锟借定锟侥碉拷前锟斤拷锟斤拷锟斤拷锟叫关★拷

锟斤拷锟杰诧拷锟斤拷锟斤拷锟叫碉拷转锟斤拷锟斤拷嵌锟斤拷锟� C 锟斤拷锟侥硷拷支锟街o拷锟斤拷锟斤拷锟斤拷锟斤拷锟� PHP 锟斤拷 strftime() 也锟斤拷支锟街★拷锟斤拷锟解,锟斤拷锟斤拷锟斤拷锟叫碉拷平台锟斤拷支锟街革拷锟斤拷时锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟节的凤拷围锟斤拷锟斤拷锟睫讹拷锟节诧拷锟斤拷锟斤拷 Unix 锟斤拷元锟斤拷锟斤拷锟斤拷味锟斤拷锟斤拷锟斤拷 %e, %T锟斤拷%R 锟斤拷 %D锟斤拷锟斤拷锟杰革拷锟洁)锟皆硷拷锟斤拷锟斤拷 Jan 1, 1970 锟斤拷时锟斤拷锟斤拷 Windows锟斤拷一些 Linux 锟斤拷锟叫版本锟斤拷锟皆硷拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷系统锟斤拷锟斤拷效锟斤拷锟斤拷锟斤拷 Windows 系统锟斤拷锟斤拷支锟街碉拷转锟斤拷锟斤拷强锟斤拷锟� » MSDN 锟斤拷站锟揭碉拷锟斤拷

锟斤拷锟斤拷

format

format 锟斤拷锟杰癸拷识锟斤拷母锟绞斤拷执锟斤拷锟斤拷锟斤拷卤锟角o拷
锟斤拷式 锟斤拷锟斤拷 锟斤拷锟斤拷值示锟斤拷
锟斤拷 --- ---
%a 锟斤拷前锟斤拷锟斤拷锟斤拷锟节硷拷锟侥硷拷写 Sun 锟斤拷 Sat
%A 锟斤拷前锟斤拷锟斤拷锟斤拷锟节硷拷锟斤拷全锟斤拷 Sunday 锟斤拷 Saturday
%d 锟铰凤拷锟叫的第硷拷锟届,十锟斤拷锟斤拷锟斤拷锟街o拷锟斤拷围锟斤拷 01 锟斤拷 31锟斤拷 01 锟斤拷 31
%e 锟铰凤拷锟叫的第硷拷锟届,十锟斤拷锟斤拷锟斤拷锟街o拷一位锟斤拷锟斤拷锟斤拷前锟斤拷锟斤拷锟揭伙拷锟斤拷崭瘢ǚ锟轿э拷锟� ' 1' 锟斤拷 '31'锟斤拷 锟斤拷 Windows 锟斤拷锟斤拷未锟斤拷锟斤拷锟斤拷实锟街★拷锟斤拷锟斤拷锟斤拷息锟斤拷锟铰凤拷锟斤拷 1 锟斤拷 31
%j 锟斤拷锟斤拷械牡诩锟斤拷欤拷锟角帮拷锟斤拷锟斤拷锟斤拷位十锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷围锟斤拷 001 锟斤拷 366锟斤拷 001 锟斤拷 366
%u 锟斤拷锟斤拷 ISO-8601 锟斤拷锟节硷拷锟斤拷十锟斤拷锟斤拷锟斤拷锟斤拷锟� [1,7]锟斤拷1 锟斤拷示锟斤拷锟斤拷一 1 (锟斤拷锟斤拷一) 锟斤拷 7 (锟斤拷锟斤拷锟斤拷)
%w 锟斤拷锟斤拷锟叫的第硷拷锟届,锟斤拷锟斤拷锟斤拷为 0 0 (锟斤拷锟斤拷锟斤拷) 锟斤拷 6 (锟斤拷锟斤拷锟斤拷)
锟斤拷 --- ---
%U 锟斤拷锟斤拷牡诩锟斤拷埽锟斤拷拥锟揭伙拷艿牡锟揭伙拷锟斤拷锟斤拷锟斤拷锟斤拷锟轿拷锟揭伙拷炜� 13 (for the 13th full week of the year)
%V %V - 锟斤拷锟斤拷诩锟斤拷艿锟� ISO-8601:1988 锟斤拷式锟斤拷锟斤拷围锟斤拷 01 锟斤拷 53锟斤拷锟斤拷 1 锟斤拷锟角憋拷锟斤拷锟揭伙拷锟斤拷锟斤拷倩锟斤拷锟� 4 锟斤拷锟斤拷锟斤拷冢锟斤拷锟斤拷锟揭伙拷锟轿匡拷艿牡锟揭伙拷臁o拷锟斤拷锟� %G 锟斤拷锟斤拷 %g 锟斤拷为指锟斤拷时锟斤拷锟斤拷锟接︼拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷伞锟斤拷锟� 01 锟斤拷 53 (where 53 accounts for an overlapping week)
%W 锟斤拷锟斤拷牡诩锟斤拷锟斤拷锟斤拷锟斤拷拥锟揭伙拷艿牡锟揭伙拷锟斤拷锟斤拷锟揭伙拷锟轿拷锟揭伙拷炜� 46 (for the 46th week of the year beginning with a Monday)
锟斤拷 --- ---
%b 锟斤拷前锟斤拷锟斤拷锟铰份的硷拷写 Jan 锟斤拷 Dec
%B 锟斤拷前锟斤拷锟斤拷锟铰份碉拷全锟斤拷 January 锟斤拷 December
%h 锟斤拷前锟斤拷锟斤拷锟铰份的硷拷写锟斤拷%b 锟侥憋拷锟斤拷锟斤拷 Jan 锟斤拷 Dec
%m 锟斤拷位锟斤拷锟斤拷锟铰凤拷 01 (锟斤拷一锟铰凤拷) 锟斤拷 12 (锟斤拷十锟斤拷锟铰凤拷)
锟斤拷 --- ---
%C 锟斤拷位锟斤拷锟斤拷示锟斤拷锟酵o拷锟斤拷莩锟斤拷锟� 100锟斤拷锟截筹拷锟斤拷锟斤拷锟斤拷 19 锟斤拷 20 锟斤拷锟斤拷
%g 2 位锟斤拷锟斤拷锟斤拷荩锟斤拷锟斤拷锟� ISO-8601:1988 锟斤拷锟斤拷锟斤拷锟斤拷锟轿硷拷 %V锟斤拷锟斤拷锟斤拷 %V 锟侥革拷式锟斤拷值一锟斤拷锟斤拷只锟斤拷锟斤拷锟斤拷锟� ISO 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷前一锟斤拷锟斤拷吆锟揭伙拷辏拷锟绞癸拷锟斤拷锟揭伙拷辍� 锟斤拷锟界:2009锟斤拷1锟斤拷6锟斤拷锟斤拷一锟斤拷锟斤拷 09锟斤拷
%G %g 锟斤拷锟斤拷锟斤拷锟斤拷位锟斤拷锟芥本 锟斤拷锟界:2009锟斤拷1锟斤拷3锟斤拷锟斤拷一锟斤拷锟斤拷 2008.
%y 锟斤拷位锟斤拷锟斤拷示锟斤拷锟� 锟斤拷锟界: 09 锟斤拷 2009锟斤拷79 锟斤拷 1979
%Y 锟斤拷位锟斤拷锟斤拷示锟斤拷锟� 锟斤拷锟界: 2038
时锟斤拷 --- ---
%H 锟斤拷 24 小时锟斤拷式锟斤拷示锟斤拷位小时锟斤拷 00 锟斤拷 23
%I 锟斤拷 12 小时锟斤拷式锟斤拷示锟斤拷位小时锟斤拷 01 锟斤拷 12
%l锟斤拷'L' 锟斤拷小写锟斤拷 锟斤拷 12 小时锟斤拷式锟斤拷示小时锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷前锟斤拷锟秸革拷 1 锟斤拷 12
%M 锟斤拷位锟侥凤拷锟斤拷锟斤拷 00 锟斤拷 59
%p 指锟斤拷时锟斤拷拇锟叫� "AM" 锟斤拷 "PM" 锟斤拷锟界: 00:31 锟斤拷 AM 锟斤拷22:23 锟斤拷PM
%P 指锟斤拷时锟斤拷锟叫⌒� "am" 锟斤拷 "pm" 锟斤拷锟界:00:31 锟斤拷 am 锟斤拷22:23 锟斤拷pm
%r 锟斤拷 "%I:%M:%S %p" 一锟斤拷 锟斤拷锟界: 21:34:17 锟斤拷 09:34:17 PM
%R 锟斤拷 "%H:%M" 一锟斤拷 锟斤拷锟界: 12:35 AM 锟斤拷 00:35锟斤拷4:44 PM 锟斤拷 16:44
%S 锟斤拷位锟斤拷锟街憋拷示锟斤拷 00 锟斤拷 59
%T 锟斤拷 "%H:%M:%S" 一锟斤拷 锟斤拷锟界: 09:34:17 PM 锟斤拷 21:34:17
%X 锟斤拷前锟斤拷锟斤拷锟斤拷选锟斤拷时锟斤拷锟绞撅拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟� 锟斤拷锟界: 03:59:16 锟斤拷 15:59:16
%z 锟斤拷 UTC 锟斤拷时锟斤拷偏锟斤拷 锟斤拷 锟斤拷写锟斤拷锟缴诧拷锟斤拷系统锟斤拷锟斤拷锟斤拷 锟斤拷锟界: 锟斤拷锟斤拷时锟斤拷锟斤拷 -0500 锟斤拷 EST
%Z %z 没锟叫革拷锟斤拷锟斤拷 UTC 锟斤拷时锟斤拷偏锟斤拷 锟斤拷 锟斤拷写锟斤拷锟缴诧拷锟斤拷系统锟斤拷锟斤拷锟斤拷 锟斤拷锟界: -0500 锟斤拷 EST 锟角讹拷锟斤拷时锟斤拷
时锟斤拷锟斤拷锟斤拷诖锟� --- ---
%c 锟斤拷前锟斤拷锟斤拷锟斤拷选锟斤拷锟斤拷锟斤拷时锟斤拷锟斤拷 锟斤拷锟界: 2009 锟斤拷 2 锟斤拷 5 锟斤拷锟斤拷锟斤拷 12:45:10 锟斤拷 Tue Feb 5 00:45:10 2009
%D 锟斤拷 "%m/%d/%y" 一锟斤拷 锟斤拷锟界: 2009 锟斤拷 2 锟斤拷 5 锟斤拷锟斤拷 02/05/09
%F Same as "%Y-%m-%d" (commonly used in database datestamps) 锟斤拷锟界:2009 锟斤拷 2 锟斤拷 5 锟斤拷锟斤拷 2009-02-05
%s Unix锟斤拷元锟斤拷时锟斤拷锟斤拷锟斤拷锟� time() 锟斤拷锟斤拷一锟斤拷锟斤拷 锟斤拷锟界: 1979 锟斤拷 9 锟斤拷 10 锟斤拷锟斤拷锟斤拷 8 锟斤拷 40 锟斤拷 00 锟斤拷锟斤拷 305815200
%x 锟斤拷前锟斤拷锟斤拷锟斤拷选锟斤拷时锟斤拷锟绞撅拷锟斤拷锟斤拷锟斤拷锟斤拷锟绞憋拷锟� 锟斤拷锟界: 2009 锟斤拷 2 锟斤拷 5 锟斤拷锟斤拷 02/05/09
锟斤拷锟斤拷 --- ---
%n 锟斤拷锟叫凤拷("\n") ---
%t Tab 锟街凤拷("\t") ---
%% 锟斤拷锟斤拷锟较的百凤拷锟街凤拷("%") ---

锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟襟长讹拷锟斤拷 1023 锟斤拷锟街凤拷锟斤拷

Warning

锟斤拷锟斤拷 ISO 9889:1999锟斤拷锟斤拷前锟斤拷 C 锟斤拷准锟斤拷锟斤拷确指锟斤拷一锟杰达拷锟斤拷锟斤拷一锟斤拷始锟斤拷锟斤拷锟斤拷 Sun Solaris 锟斤拷一锟斤拷锟狡猴拷锟斤拷锟斤拷锟斤拷锟届开始锟斤拷锟斤拷为 1锟斤拷锟斤拷锟斤拷 %u 锟侥斤拷锟揭诧拷锟斤拷锟斤拷锟街诧拷锟斤拷锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷

Warning

锟斤拷锟斤拷锟� Windows锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟� %e 锟斤拷锟轿凤拷锟斤拷锟轿凤拷锟斤拷锟斤拷锟斤拷支锟斤拷 Windows锟斤拷 为锟剿得碉拷锟斤拷锟街碉拷锟斤拷锟斤拷锟� %#d 锟斤拷锟轿凤拷锟斤拷锟斤拷锟芥。锟斤拷锟斤拷说锟斤拷锟斤拷锟斤拷锟叫匆伙拷锟斤拷锟狡教ㄖэ拷值暮锟斤拷锟斤拷锟�

Warning

锟斤拷锟斤拷锟� Mac OS X锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟� %P 锟斤拷锟轿凤拷锟斤拷锟斤拷锟斤拷支锟斤拷 Mac OS X锟斤拷

timestamp

锟斤拷选锟斤拷 timestamp 锟斤拷锟斤拷锟斤拷一锟斤拷 integer 锟斤拷 Unix 时锟斤拷锟斤拷锟斤拷锟轿粗革拷锟斤拷锟斤拷锟斤拷锟街的拷锟轿拷锟角帮拷锟斤拷锟绞憋拷洹R诧拷锟斤拷锟剿碉拷锟斤拷锟街的拷锟轿� time() 锟侥凤拷锟斤拷值锟斤拷

锟斤拷锟斤拷值

锟斤拷锟斤拷指锟斤拷锟斤拷 timestamp 锟斤拷未锟斤拷锟斤拷 timestamp 锟斤拷使锟矫碉拷前锟斤拷锟斤拷时锟戒, 锟斤拷锟斤拷 format 锟斤拷式锟斤拷锟斤拷锟街凤拷锟斤拷 锟铰份★拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷氐锟斤拷址锟斤拷锟斤拷锟斤拷锟� setlocale() 锟斤拷锟矫的碉拷前锟斤拷锟斤拷锟斤拷锟矫★拷

锟斤拷锟斤拷锟届常

锟斤拷每 锟轿碉拷锟斤拷锟斤拷锟斤拷/时锟戒函锟斤拷时锟斤拷锟斤拷锟绞憋拷锟斤拷锟叫э拷锟斤拷锟斤拷锟斤拷 E_NOTICE 锟斤拷锟斤拷锟斤拷锟绞癸拷锟较低筹拷瓒ㄖ碉拷锟� TZ 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟� E_STRICT 锟斤拷 E_WARNING 锟斤拷息锟斤拷锟轿硷拷 date_default_timezone_set()锟斤拷

锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟� C 锟解,锟斤拷锟斤拷一些转锟斤拷锟斤拷遣锟斤拷锟斤拷锟街э拷帧锟� 锟斤拷 Windows 锟较o拷使锟斤拷未知锟斤拷转锟斤拷锟斤拷墙锟斤拷锟斤拷锟� 5 E_WARNING 锟斤拷息锟斤拷锟斤拷锟斤拷锟斤拷 FALSE锟斤拷 锟斤拷锟斤拷锟斤拷锟侥诧拷锟斤拷系统锟较o拷锟斤拷锟斤拷懿锟斤拷艿玫锟斤拷魏锟� E_WARNING 锟斤拷息锟斤拷 锟斤拷锟揭匡拷锟斤拷锟斤拷锟轿达拷锟阶拷锟斤拷锟阶拷锟斤拷锟角★拷

锟斤拷锟斤拷锟斤拷志

锟芥本 说锟斤拷
5.1.0

锟斤拷锟节凤拷锟斤拷 E_STRICT 锟斤拷 E_NOTICE 时锟斤拷锟斤拷锟斤拷

锟斤拷锟斤拷

锟斤拷锟斤拷锟斤拷系统锟斤安装锟剿革拷锟皆碉拷锟斤拷锟皆伙拷锟斤拷锟斤拷锟斤拷锟斤拷锟杰癸拷锟斤拷锟斤拷锟斤拷锟叫★拷

Example #1 strftime() 锟斤拷锟斤拷锟斤拷锟斤拷锟�

<?php
setlocale
(LC_TIME"C");
echo 
strftime("%A");
setlocale(LC_TIME"fi_FI");
echo 
strftime(" in Finnish is %A,");
setlocale(LC_TIME"fr_FR");
echo 
strftime(" in French %A and");
setlocale(LC_TIME"de_DE");
echo 
strftime(" in German %A.\n");
?>

Example #2 ISO 8601:1988 week number example

<?php
/*     December 2002 / January 2003
ISOWk  M   Tu  W   Thu F   Sa  Su
----- ----------------------------
51     16  17  18  19  20  21  22
52     23  24  25  26  27  28  29
1      30  31   1   2   3   4   5
2       6   7   8   9  10  11  12
3      13  14  15  16  17  18  19   */

// 锟斤拷锟斤拷锟� 12/28/2002 - %V,%G,%Y = 52,2002,2002
echo "12/28/2002 - %V,%G,%Y = " strftime("%V,%G,%Y"strtotime("12/28/2002")) . "\n";

// 锟斤拷锟斤拷锟� 12/30/2002 - %V,%G,%Y = 1,2003,2002
echo "12/30/2002 - %V,%G,%Y = " strftime("%V,%G,%Y"strtotime("12/30/2002")) . "\n";

// 锟斤拷锟斤拷锟� 1/3/2003 - %V,%G,%Y = 1,2003,2003
echo "1/3/2003 - %V,%G,%Y = " strftime("%V,%G,%Y",strtotime("1/3/2003")) . "\n";

// 锟斤拷锟斤拷锟� 1/10/2003 - %V,%G,%Y = 2,2003,2003
echo "1/10/2003 - %V,%G,%Y = " strftime("%V,%G,%Y",strtotime("1/10/2003")) . "\n";



/*     December 2004 / January 2005
ISOWk  M   Tu  W   Thu F   Sa  Su
----- ----------------------------
51     13  14  15  16  17  18  19
52     20  21  22  23  24  25  26
53     27  28  29  30  31   1   2
1       3   4   5   6   7   8   9
2      10  11  12  13  14  15  16   */

// 锟斤拷锟斤拷锟� 12/23/2004 - %V,%G,%Y = 52,2004,2004
echo "12/23/2004 - %V,%G,%Y = " strftime("%V,%G,%Y",strtotime("12/23/2004")) . "\n";

// 锟斤拷锟斤拷锟� 12/31/2004 - %V,%G,%Y = 53,2004,2004
echo "12/31/2004 - %V,%G,%Y = " strftime("%V,%G,%Y",strtotime("12/31/2004")) . "\n";

// 锟斤拷锟斤拷锟� 1/2/2005 - %V,%G,%Y = 53,2004,2005
echo "1/2/2005 - %V,%G,%Y = " strftime("%V,%G,%Y",strtotime("1/2/2005")) . "\n";

// 锟斤拷锟斤拷锟� 1/3/2005 - %V,%G,%Y = 1,2005,2005
echo "1/3/2005 - %V,%G,%Y = " strftime("%V,%G,%Y",strtotime("1/3/2005")) . "\n";

?>

Example #3 %e 锟睫革拷锟斤拷锟斤拷平台锟斤拷锟捷碉拷锟斤拷锟斤拷

<?php

// Jan 1: results in: '%e%1%' (%%, e, %%, %e, %%)
$format '%%e%%%e%%';

// Check for Windows to find and replace the %e 
// modifier correctly
if (strtoupper(substr(PHP_OS03)) == 'WIN') {
    
$format preg_replace('#(?<!%)((?:%%)*)%e#''</refsect1>%#d'$format);
}

echo 
strftime($format);
?>

Example #4 锟斤拷示锟斤拷锟斤拷锟斤拷知锟斤拷未知锟侥革拷式

<?php
// Describe the formats.
$strftimeFormats = array(
    
'A' => 'A full textual representation of the day',
    
'B' => 'Full month name, based on the locale',
    
'C' => 'Two digit representation of the century (year divided by 100, truncated to an integer)',
    
'D' => 'Same as "%m/%d/%y"',
    
'E' => '',
    
'F' => 'Same as "%Y-%m-%d"',
    
'G' => 'The full four-digit version of %g',
    
'H' => 'Two digit representation of the hour in 24-hour format',
    
'I' => 'Two digit representation of the hour in 12-hour format',
    
'J' => '',
    
'K' => '',
    
'L' => '',
    
'M' => 'Two digit representation of the minute',
    
'N' => '',
    
'O' => '',
    
'P' => 'lower-case "am" or "pm" based on the given time',
    
'Q' => '',
    
'R' => 'Same as "%H:%M"',
    
'S' => 'Two digit representation of the second',
    
'T' => 'Same as "%H:%M:%S"',
    
'U' => 'Week number of the given year, starting with the first Sunday as the first week',
    
'V' => 'ISO-8601:1988 week number of the given year, starting with the first week of the year with at least 4 weekdays, with Monday being the start of the week',
    
'W' => 'A numeric representation of the week of the year, starting with the first Monday as the first week',
    
'X' => 'Preferred time representation based on locale, without the date',
    
'Y' => 'Four digit representation for the year',
    
'Z' => 'The time zone offset/abbreviation option NOT given by %z (depends on operating system)',
    
'a' => 'An abbreviated textual representation of the day',
    
'b' => 'Abbreviated month name, based on the locale',
    
'c' => 'Preferred date and time stamp based on local',
    
'd' => 'Two-digit day of the month (with leading zeros)',
    
'e' => 'Day of the month, with a space preceding single digits',
    
'f' => '',
    
'g' => 'Two digit representation of the year going by ISO-8601:1988 standards (see %V)',
    
'h' => 'Abbreviated month name, based on the locale (an alias of %b)',
    
'i' => '',
    
'j' => 'Day of the year, 3 digits with leading zeros',
    
'k' => '',
    
'l' => 'Hour in 12-hour format, with a space preceeding single digits',
    
'm' => 'Two digit representation of the month',
    
'n' => 'A newline character ("\n")',
    
'o' => '',
    
'p' => 'UPPER-CASE "AM" or "PM" based on the given time',
    
'q' => '',
    
'r' => 'Same as "%I:%M:%S %p"',
    
's' => 'Unix Epoch Time timestamp',
    
't' => 'A Tab character ("\t")',
    
'u' => 'ISO-8601 numeric representation of the day of the week',
    
'v' => '',
    
'w' => 'Numeric representation of the day of the week',
    
'x' => 'Preferred date representation based on locale, without the time',
    
'y' => 'Two digit representation of the year',
    
'z' => 'Either the time zone offset from UTC or the abbreviation (depends on operating system)',
    
'%' => 'A literal percentage character ("%")',
);

// Results.
$strftimeValues = array();

// Evaluate the formats whilst suppressing any errors.
foreach($strftimeFormats as $format => $description){
    if (
False !== ($value = @strftime("%{$format}"))){
        
$strftimeValues[$format] = $value;
    }
}

// Find the longest value.
$maxValueLength max(array_map('strlen'$strftimeValues));

// Report known formats.
foreach($strftimeValues as $format => $value){
    echo 
"Known format   : '{$format}' = "str_pad("'{$value}'"$maxValueLength), " ( {$strftimeFormats[$format]} )\n";
}

// Report unknown formats.
foreach(array_diff_key($strftimeFormats$strftimeValues) as $format => $description){
    echo 
"Unknown format : '{$format}'   "str_pad(' '$maxValueLength), ($description " ( {$description} )" ''), "\n";
}
?>

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

Known format   : 'A' = 'Friday'            ( A full textual representation of the day )
Known format   : 'B' = 'December'          ( Full month name, based on the locale )
Known format   : 'H' = '11'                ( Two digit representation of the hour in 24-hour format )
Known format   : 'I' = '11'                ( Two digit representation of the hour in 12-hour format )
Known format   : 'M' = '24'                ( Two digit representation of the minute )
Known format   : 'S' = '44'                ( Two digit representation of the second )
Known format   : 'U' = '48'                ( Week number of the given year, starting with the first Sunday as the first week )
Known format   : 'W' = '48'                ( A numeric representation of the week of the year, starting with the first Monday as the first week )
Known format   : 'X' = '11:24:44'          ( Preferred time representation based on locale, without the date )
Known format   : 'Y' = '2010'              ( Four digit representation for the year )
Known format   : 'Z' = 'GMT Standard Time' ( The time zone offset/abbreviation option NOT given by %z (depends on operating system) )
Known format   : 'a' = 'Fri'               ( An abbreviated textual representation of the day )
Known format   : 'b' = 'Dec'               ( Abbreviated month name, based on the locale )
Known format   : 'c' = '12/03/10 11:24:44' ( Preferred date and time stamp based on local )
Known format   : 'd' = '03'                ( Two-digit day of the month (with leading zeros) )
Known format   : 'j' = '337'               ( Day of the year, 3 digits with leading zeros )
Known format   : 'm' = '12'                ( Two digit representation of the month )
Known format   : 'p' = 'AM'                ( UPPER-CASE "AM" or "PM" based on the given time )
Known format   : 'w' = '5'                 ( Numeric representation of the day of the week )
Known format   : 'x' = '12/03/10'          ( Preferred date representation based on locale, without the time )
Known format   : 'y' = '10'                ( Two digit representation of the year )
Known format   : 'z' = 'GMT Standard Time' ( Either the time zone offset from UTC or the abbreviation (depends on operating system) )
Known format   : '%' = '%'                 ( A literal percentage character ("%") )
Unknown format : 'C'                       ( Two digit representation of the century (year divided by 100, truncated to an integer) )
Unknown format : 'D'                       ( Same as "%m/%d/%y" )
Unknown format : 'E'
Unknown format : 'F'                       ( Same as "%Y-%m-%d" )
Unknown format : 'G'                       ( The full four-digit version of %g )
Unknown format : 'J'
Unknown format : 'K'
Unknown format : 'L'
Unknown format : 'N'
Unknown format : 'O'
Unknown format : 'P'                       ( lower-case "am" or "pm" based on the given time )
Unknown format : 'Q'
Unknown format : 'R'                       ( Same as "%H:%M" )
Unknown format : 'T'                       ( Same as "%H:%M:%S" )
Unknown format : 'V'                       ( ISO-8601:1988 week number of the given year, starting with the first week of the year with at least 4 weekdays, with Monday being the start of the week )
Unknown format : 'e'                       ( Day of the month, with a space preceding single digits )
Unknown format : 'f'
Unknown format : 'g'                       ( Two digit representation of the year going by ISO-8601:1988 standards (see %V) )
Unknown format : 'h'                       ( Abbreviated month name, based on the locale (an alias of %b) )
Unknown format : 'i'
Unknown format : 'k'
Unknown format : 'l'                       ( Hour in 12-hour format, with a space preceeding single digits )
Unknown format : 'n'                       ( A newline character ("\n") )
Unknown format : 'o'
Unknown format : 'q'
Unknown format : 'r'                       ( Same as "%I:%M:%S %p" )
Unknown format : 's'                       ( Unix Epoch Time timestamp )
Unknown format : 't'                       ( A Tab character ("\t") )
Unknown format : 'u'                       ( ISO-8601 numeric representation of the day of the week )
Unknown format : 'v'

注锟斤拷

Note: %G 锟斤拷 %V锟斤拷锟斤拷锟斤拷锟斤拷直锟斤拷系统未锟杰筹拷锟斤拷锟解,锟斤拷锟斤拷 ISO 8601:1988 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟杰得筹拷未预锟节的斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 %V 锟斤拷锟斤拷锟铰碉拷锟斤拷锟接★拷

锟轿硷拷