一般日期函数的常量
不论什么时候 Zend_Date 方法需要参数 $parts ,下面常数中其中之一可担当此任,
用来选择日期的特定部分或指示日期使用的或期望使用的格式(例如 RFC 822)。
使用常数
例如,常数 Zend_Date::HOUR 可以像下列所示来使用。当和星期几、日期、小时、分钟、秒和任何其它因位于世界不同的地方而不同地表示的日期部分一起使用时,
对象的时区将自动用来计算当前值,即使是内部的时间戳和此刻一致并且不论用户的地理位置在世界的何方。
不管使用了哪些单元,输出必需表达为 GMT/UTC 或本地化。下面的输出例子反映了 Europe/GMT+1 hour (e.g. Germany, Austria, France) 的本地化。
Zend_Date::HOUR 的操作
函数/输入 |
描述 |
原始日期 |
效果/输出 |
get(Zend_Date::HOUR) |
Output of the hour |
2009-02-13T14:53:27+01:00 |
14 |
set(12, Zend_Date::HOUR) |
Set new hour |
2009-02-13T14:53:27+01:00 |
2009-02-13T12:53:27+01:00 |
add(12, Zend_Date::HOUR) |
Add hours |
2009-02-13T14:53:27+01:00 |
2009-02-14T02:53:27+01:00 |
sub(12, Zend_Date::HOUR) |
Subtract hours |
2009-02-13T14:53:27+01:00 |
2009-02-13T02:53:27+01:00 |
compare(12, Zend_Date::HOUR) |
Compare hour, returns 0, 1 or -1 |
2009-02-13T14:53:27+01:00 |
1 (if object > argument) |
copy(Zend_Date::HOUR) |
Copies only the hour part |
2009-02-13T14:53:27+01:00 |
1970-01-01T14:00:00+01:00 |
equals(14, Zend_Date::HOUR) |
Compares the hour, returns TRUE or FALSE |
2009-02-13T14:53:27+01:00 |
TRUE |
isEarlier(12, Zend_Date::HOUR) |
Compares the hour, returns TRUE or FALSE |
2009-02-13T14:53:27+01:00 |
TRUE |
isLater(12, Zend_Date::HOUR) |
Compares the hour, returns TRUE or FALSE |
2009-02-13T14:53:27+01:00 |
FALSE |
所有常数列表
在 Zend_Date 中每个日期/时间的部分都有独一无二的常数。所有 Zend_Date 支持的常数如下:
Day Constants
常数 |
描述 |
日期 |
受影响部分/例子 |
Zend_Date::DAY |
Day (as a number, two digit) |
2009-02-06T14:53:27+01:00 |
2009-02-06T14:53:27+01:00 (06) |
Zend_Date::DAY_SHORT |
Day (as a number, one or two digit) |
2009-02-06T14:53:27+01:00 |
2009-02-06T14:53:27+01:00 (6) |
Zend_Date::WEEKDAY |
Weekday (Name of the day, localized, complete) |
2009-02-06T14:53:27+01:00 |
Friday
|
Zend_Date::WEEKDAY_SHORT |
Weekday (Name of the day, localized, abbreviated, the first three digits) |
2009-02-06T14:53:27+01:00 |
Fre for Friday |
Zend_Date::WEEKDAY_NAME |
Weekday (Name of the day, localized, abbreviated, the first two digits) |
2009-02-06T14:53:27+01:00 |
Fr for Friday |
Zend_Date::WEEKDAY_NARROW |
Weekday (Name of the day, localized, abbreviated, only the first digit) |
2009-02-06T14:53:27+01:00 |
F for Friday |
Zend_Date::WEEKDAY_DIGIT |
Weekday (0 = Sunday, 6 = Saturday) |
2009-02-06T14:53:27+01:00 |
5 for Friday |
Zend_Date::WEEKDAY_8601 |
Weekday according to ISO 8601 (1 = Monday, 7 = Sunday) |
2009-02-06T14:53:27+01:00 |
5 for Friday |
Zend_Date::DAY_OF_YEAR |
Day (as a number, one or two digit) |
2009-02-06T14:53:27+01:00 |
43
|
Zend_Date::DAY_SUFFIX |
English addendum for the day (st, nd, rd, th) |
2009-02-06T14:53:27+01:00 |
th
|
星期常数
常数 |
描述 |
日期 |
受影响部分/例子 |
Zend_Date::WEEK |
Week (as a number, 1-53) |
2009-02-06T14:53:27+01:00 |
7
|
月常数
常数 |
描述 |
日期 |
受影响部分/例子 |
Zend_Date::MONTH_NAME |
Month (Name of the month, localized, complete) |
2009-02-06T14:53:27+01:00 |
February
|
Zend_Date::MONTH_NAME_SHORT |
Month (Name of the month, localized, abbreviated, three digit) |
2009-02-06T14:53:27+01:00 |
Feb
|
Zend_Date::MONTH_NAME_NARROW |
Month (Name of the month, localized, abbreviated, one digit) |
2009-02-06T14:53:27+01:00 |
F
|
Zend_Date::MONTH |
Month (Number of the month, two digit) |
2009-02-06T14:53:27+01:00 |
2009-02-06T14:53:27+01:00 (02) |
Zend_Date::MONTH_SHORT |
Month (Number of the month, one or two digit) |
2009-02-06T14:53:27+01:00 |
2009-02-06T14:53:27+01:00 (2) |
Zend_Date::MONTH_DAYS |
Number of days for this month (number) |
2009-02-06T14:53:27+01:00 |
28
|
年常数
常数 |
描述 |
日期 |
受影响部分/例子 |
Zend_Date::YEAR |
Year (number) |
2009-02-06T14:53:27+01:00 |
2009-02-06T14:53:27+01:00 |
Zend_Date::YEAR_8601 |
Year according to ISO 8601 (number) |
2009-02-06T14:53:27+01:00 |
2009
|
Zend_Date::YEAR_SHORT |
Year (number, two digit) |
2009-02-06T14:53:27+01:00 |
2009-02-06T14:53:27+01:00 |
Zend_Date::YEAR_SHORT_8601 |
Year according to ISO 8601 (number, two digit) |
2009-02-06T14:53:27+01:00 |
09
|
Zend_Date::LEAPYEAR |
Is the year a leap year? (TRUE or FALSE) |
2009-02-06T14:53:27+01:00 |
FALSE
|
时间常数
常数 |
描述 |
日期 |
受影响部分/例子 |
Zend_Date::HOUR |
Hour (00-23, two digit) |
2009-02-06T14:53:27+01:00 |
14
|
Zend_Date::HOUR_SHORT |
Hour (0-23, one or two digit) |
2009-02-06T14:53:27+01:00 |
14
|
Zend_Date::HOUR_SHORT_AM |
Hour (1-12, one or two digit) |
2009-02-06T14:53:27+01:00 |
2
|
Zend_Date::HOUR_AM |
Hour (01-12, two digit) |
2009-02-06T14:53:27+01:00 |
02
|
Zend_Date::MINUTE |
Minute (00-59, two digit) |
2009-02-06T14:53:27+01:00 |
2009-02-06T14:53:27+01:00 |
Zend_Date::MINUTE_SHORT |
Minute (0-59, one or two digit) |
2009-02-06T14:03:27+01:00 |
2009-02-06T14:03:27+01:00 |
Zend_Date::SECOND |
Second (00-59, two digit) |
2009-02-06T14:53:27+01:00 |
2009-02-06T14:53:27+01:00 |
Zend_Date::SECOND_SHORT |
Second (0-59, one or two digit) |
2009-02-06T14:53:07+01:00 |
2009-02-06T14:53:07+01:00 |
Zend_Date::MILLISECOND |
Millisecond (theoretically infinite) |
2009-02-06T14:53:27.20546 |
2009-02-06T14:53:27.20546
|
Zend_Date::MERIDIEM |
Time of day (forenoon/afternoon) |
2009-02-06T14:53:27+01:00 |
afternoon
|
Zend_Date::SWATCH |
Swatch Internet Time |
2009-02-06T14:53:27+01:00 |
620
|
时区常数
常数 |
描述 |
日期 |
受影响部分/例子 |
Zend_Date::TIMEZONE |
Name der time zone (string, abbreviated) |
2009-02-06T14:53:27+01:00 |
CET
|
Zend_Date::TIMEZONE_NAME |
Name of the time zone (string, complete) |
2009-02-06T14:53:27+01:00 |
Europe/Paris
|
Zend_Date::TIMEZONE_SECS |
Difference of the time zone to GMT in seconds (integer) |
2009-02-06T14:53:27+01:00 |
3600 seconds to GMT |
Zend_Date::GMT_DIFF |
Difference to GMT in seconds (string) |
2009-02-06T14:53:27+01:00 |
+0100
|
Zend_Date::GMT_DIFF_SEP |
Difference to GMT in seconds (string, separated) |
2009-02-06T14:53:27+01:00 |
+01:00
|
Zend_Date::DAYLIGHT |
Summer time or Winter time? (TRUE or FALSE) |
2009-02-06T14:53:27+01:00 |
FALSE
|
日期格式常数(格式包括时区)
常数 |
描述 |
日期 |
受影响部分/例子 |
Zend_Date::ISO_8601 |
Date according to ISO 8601 (string, complete) |
2009-02-13T14:53:27+01:00 |
2009-02-13T14:53:27+01:00
|
Zend_Date::RFC_2822 |
Date according to RFC 2822 (string) |
2009-02-13T14:53:27+01:00 |
Fri, 13 Feb 2009 14:53:27 +0100
|
Zend_Date::TIMESTAMP |
» Unix time (seconds since 1.1.1970, mixed) |
2009-02-13T14:53:27+01:00 |
1234533207
|
Zend_Date::ATOM |
Date according to ATOM (string) |
2009-02-13T14:53:27+01:00 |
2009-02-13T14:53:27+01:00
|
Zend_Date::COOKIE |
Date for Cookies (string, for Cookies) |
2009-02-13T14:53:27+01:00 |
Friday, 13-Feb-09 14:53:27 Europe/Paris
|
Zend_Date::RFC_822 |
Date according to RFC 822 (string) |
2009-02-13T14:53:27+01:00 |
Fri, 13 Feb 09 14:53:27 +0100
|
Zend_Date::RFC_850 |
Date according to RFC 850 (string) |
2009-02-13T14:53:27+01:00 |
Friday, 13-Feb-09 14:53:27 Europe/Paris
|
Zend_Date::RFC_1036 |
Date according to RFC 1036 (string) |
2009-02-13T14:53:27+01:00 |
Fri, 13 Feb 09 14:53:27 +0100
|
Zend_Date::RFC_1123 |
Date according to RFC 1123 (string) |
2009-02-13T14:53:27+01:00 |
Fri, 13 Feb 2009 14:53:27 +0100
|
Zend_Date::RSS |
Date for RSS Feeds (string) |
2009-02-13T14:53:27+01:00 |
Fri, 13 Feb 2009 14:53:27 +0100
|
Zend_Date::W3C |
Date for HTML/HTTP according to W3C (string) |
2009-02-13T14:53:27+01:00 |
2009-02-13T14:53:27+01:00
|
特别注意 Zend_Date::DATES ,因为这个格式指示器在 Zend_Date 之内有个唯一的属性作为 输入 格式指示器。
当 $part 用作一个输入格式,该常量提灵活地接受许多相似的日期格式。启发式自动从输入字符串里解析并“修改”日期里的简单的错误(如果有的话),如当需要时,交换年月日的位置。
日期和时间格式 (format varies by locale)
常数 |
描述 |
日期 |
受影响部分/例子 |
Zend_Date::ERA |
Epoch (string, localized, abbreviated) |
2009-02-06T14:53:27+01:00 |
AD (anno Domini) |
Zend_Date::ERA_NAME |
Epoch (string, localized, complete) |
2009-02-06T14:53:27+01:00 |
anno domini (anno Domini) |
Zend_Date::DATES
|
Standard date (string, localized, default value). |
2009-02-13T14:53:27+01:00 |
13.02.2009
|
Zend_Date::DATE_FULL |
Complete date (string, localized, complete) |
2009-02-13T14:53:27+01:00 |
Friday, 13. February 2009
|
Zend_Date::DATE_LONG |
Long date (string, localized, long) |
2009-02-13T14:53:27+01:00 |
13. February 2009
|
Zend_Date::DATE_MEDIUM |
Normal date (string, localized, normal) |
2009-02-13T14:53:27+01:00 |
13.02.2009
|
Zend_Date::DATE_SHORT |
Abbreviated Date (string, localized, abbreviated) |
2009-02-13T14:53:27+01:00 |
13.02.09
|
Zend_Date::TIMES |
Standard time (string, localized, default value) |
2009-02-13T14:53:27+01:00 |
14:53:27
|
Zend_Date::TIME_FULL |
Complete time (string, localized, complete) |
2009-02-13T14:53:27+01:00 |
14:53 Uhr CET
|
Zend_Date::TIME_LONG |
Long time (string, localized, Long) |
2009-02-13T14:53:27+01:00 |
14:53:27 CET
|
Zend_Date::TIME_MEDIUM |
Normal time (string, localized, normal) |
2009-02-13T14:53:27+01:00 |
14:53:27
|
Zend_Date::TIME_SHORT |
Abbreviated time (string, localized, abbreviated) |
2009-02-13T14:53:27+01:00 |
14:53
|
|
|