gmdate()函数 参数详解

发布时间:2009年02月10日      浏览次数:1367 次
Definition and Usage
定义和用法
The gmdate() function formats a GMT/UTC date/time.
gmdate()函数的作用是:格式化一个GMT/UTC日期/时间。
Syntax
语法
gmdate(format,timestamp)
Parameter参数 Description描述
format Required. Specifies how to return the result:
必要参数。指定返回结果的方式:
d - The day of the month (from 01 to 31)
d – 一个月包含的天数(从01号到31号)
D - A textual representation of a day (three letters)
D – 关于某一天是星期几的文本陈述(用三个字母表示,如:Jan、Fre等)
j - The day of the month without leading zeros (1 to 31)
j -一个月包含的天数,数字前不包含0(从1号到31号)
l (lowercase 'L') - A full textual representation of a day
l(‘L’的小写形式)- 表示当天星期几的完整文本
N - The ISO-8601 numeric representation of a day (1 for Monday through 7 for Sunday)
N – 用ISO-8061的数字格式表示一天是星期几(如:1表示Monday[星期一]、7表示Sunday[星期日])
S - The English ordinal suffix for the day of the month (2 characters st, nd, rd or th. Works well with j)
S – 在日子后加英文后缀(它有两个英文字母组成:st、nd或th,它通常和上述的“j”在一起使用,如:1st,2nd,3rd,4th)
w - A numeric representation of the day (0 for Sunday through 6 for Saturday)
w – 表示星期几的数字(0表示Sunday[星期日],6表示Saturday[星期六])
z - The day of the year (from 0 through 365)
z – 一年当包含的天数(从0到365)
W - The ISO-8601 week number of year (weeks starting on Monday)
W - 用ISO-8061的数字格式表示一年中的星期(始于Monday[星期一])
F - A full textual representation of a month (January through December)
F – 关于月份的完整文本描述(从January[一月份]开始到Decemeber[十二月份])
m - A numeric representation of a month (from 01 to 12)
m – 用数值形式表示月份(从01到12)
M - A short textual representation of a month (three letters)
M – 用于表示月份的简写文本形式(三个字母表示,如:Jan、Fre……)
n - A numeric representation of a month, without leading zeros (1 to 12)
n -用数值形式表示月份,数字前不包含零(从1到12)
t - The number of days in the given month
t – 给定月份中包含的天数
L - Whether it's a leap year (1 if it is a leap year, 0 otherwise)
L – 指定是否是闰年(1表示闰年;0不是)
o - The ISO-8601 year number
o – ISO-8601标准下的年份数字
Y - A four digit representation of a year
Y – 表示年份的四位数字
y - A two digit representation of a year
y – 用两位数的形式表示的年份数字
a - Lowercase am or pm
a – 小写形式表示:am 或 pm
A - Uppercase AM or PM
A – 大写形式表示:AM 或 PM
B - Swatch Internet time (000 to 999)
B – Swatch网络时间(000到999)
g - 12-hour format of an hour (1 to 12)
g – 12小时格式(1到12)
G - 24-hour format of an hour (0 to 23)
G – 24小时格式(0到23)
h - 12-hour format of an hour (01 to 12)
h – 12小时格式(01到12)
H - 24-hour format of an hour (00 to 23)
H – 24小时格式(00到23)
i - Minutes with leading zeros (00 to 59)
i – 分钟表示格式(00到59)
s - Seconds, with leading zeros (00 to 59)
s – 秒表示格式(00到59)
e - The timezone identifier (Examples: UTC, Atlantic/Azores)
e – 时区标志符(如:UTC, Atlantic/Azores)
I (capital i) - Whether the date is in daylights savings time (1 if Daylight Savings Time, 0 otherwise)
I(“i”的大写形式)- 指名是否是夏令时(1表示夏令时;0表示不是夏令时)
O - Difference to Greenwich time (GMT) in hours (Example: +0100)
O – 表示GMT格式时间的差异(如:+0100)
T - Timezone setting of the PHP machine (Examples: EST, MDT)
T – PHP服务器的时区设置(如:EST, MDT)
Z - Returns 0
Z - 返回0
c - The ISO-8601 date (e.g. 2004-02-12T15:19:21+00:00)
c – ISO-8601标准的日期(例如:2004-02-12T15:19:21+00:00)
r - The RFC 2822 formatted date (e.g. Thu, 21 Dec 2000 16:01:07 +0200)
r – RFC 2822格式的日期(例如:Thu, 21 Dec 2000 16:01:07 +0200)
U - The seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
U – 以Unix Epoch为准计算经过的秒数(January 1 1970 00:00:00 GMT)

timestamp Optional.
可选参数。指定时间戳
--------------------------------------------------------------------------------
Example
案例
<?php
echo("Result with date():<br />");
echo(date("l") . "<br />");
echo(date("l dS \of F Y h:i:s A") . "<br />");
echo("Oct 3,1975 was on a ".date("l", mktime(0,0,0,10,3,1975))."<br />");
echo(date(DATE_RFC822) . "<br />");
echo(date(DATE_ATOM,mktime(0,0,0,10,3,1975)) . "<br /><br />");echo("Result with gmdate():<br />");
echo(gmdate("l") . "<br />");
echo(gmdate("l dS \of F Y h:i:s A") . "<br />");
echo("Oct 3,1975 was on a ".gmdate("l", mktime(0,0,0,10,3,1975))."<br />");
echo(gmdate(DATE_RFC822) . "<br />");
echo(gmdate(DATE_ATOM,mktime(0,0,0,10,3,1975)) . "<br />");
?>
The output of the code above could be something like this:
上述代码将输出下面的结果:
Result with date():
Tuesday
Tuesday 24th of January 2006 02:41:22 PM
Oct 3,1975 was on a Friday
Tue, 24 Jan 2006 14:41:22 CET
1975-10-03T00:00:00+0100Result with gmdate():
Tuesday
Tuesday 24th of January 2006 01:41:22 PM
Oct 3,1975 was on a Thursday
Tue, 24 Jan 2006 13:41:22 GMT
1975-10-02T23:00:00+0000
免责声明:本站相关技术文章信息部分来自网络,目的主要是传播更多信息,如果您认为本站的某些信息侵犯了您的版权,请与我们联系,我们会即时妥善的处理,谢谢合作!