PHP/时间范例大全

                                                              PHP/时间范例大全

2010-12-15 15:25:11

由于对时间函数很有恐惧感,决定好好写个demo

PHP时间函数范例:

代码:

代码简要说明:主要有两个函数:showTime($timeFormat)和desc($descTime) ;

前者根据传递的格式显示时间,后者表示描述;

PHP 时间和日期函数范例

当前时间:2010-12-15T08:23:02+01:00

格式时间描述
Day
D M YWed Dec 2010//D--A textual representation of a day, three letters
d M Y15 Dec 2010//d--Day of the month, 2 digits with leading zeros
j M Y15 Dec 2010//j--Day of the month without leading zeros
l M YWednesday Dec 2010//l--A full textual representation of the day of the week
N M Y3 Dec 2010//N --ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0)
dS M Y15th Dec 2010//S-- english ordinal suffix for the day of the month, 2 characters
w M Y3 Dec 2010// w-- the day of week.
w z Y3 348 2010// z --The day of the year.
Week
W50//W--ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0)
Month
l F YWednesday December 2010// F -- A full textual representation of a month, such as January or March
d m Y15 12 2010//m --Numeric representation of a month, with leading zeros
D M YWed Dec 2010//M --A short textual representation of a month, three letters
dS n Y15th 12 2010//n --Numeric representation of a month, without leading zeros
t /d/a/y/s /i/n /m/o/n/t/h F31 days in month December// t--Number of days in the given month
Year
/L/e/a/p /Y/e/a/r: LLeap Year: 0//L --Whether it's a leap year
d m o15 12 2010//o--ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0)
d m Y15 12 2010//Y--A full numeric representation of a year, 4 digits
d m y15 12 10//y--A two digit representation of a year
Time
D M Y aWed Dec 2010 am//a --Lowercase Ante meridiem and Post meridiem
D M Y AWed Dec 2010 AM//A --Uppercase Ante meridiem and Post meridiem
D M Y BWed Dec 2010 349//B --Swatch Internet time
D M Y gWed Dec 2010 8//g --12-hour format of an hour without leading zeros
D M Y GWed Dec 2010 8//G --24-hour format of an hour without leading zeros
D M Y hWed Dec 2010 08//h --12-hour format of an hour with leading zeros
D M Y HWed Dec 2010 08//H --24-hour format of an hour with leading zeros
D M Y iWed Dec 2010 23//i --Minutes with leading zeros
D M Y sWed Dec 2010 02//s --Seconds, with leading zeros
D M Y uWed Dec 2010 000000//u --Microseconds (added in PHP 5.2.2)
D M Y g:i:sWed Dec 2010 8:23:02show the time
Timezone
eEurope/Paris//e --Timezone identifier (added in PHP 5.1.0)
/i/n /d/a/y/l/i/g/h/t Iin daylight 0//I (capital i) --Whether or not the date is in daylight saving time
O+0100//O -- Difference to Greenwich time (GMT) in hours
P+01:00//P -- Difference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3)
TCET//T --Timezone abbreviation
Z3600//Z --Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.
Full Date/Time
c2010-12-15T08:23:02+01:00//c --ISO 8601 date (added in PHP 5)
rWed, 15 Dec 2010 08:23:02 +0100//r --? RFC 2822 formatted date
U1292397782//Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值