Constants for General Date Functions
Whenever a Zend_Date method has a $parts
parameter, one of the constants below can be used as the argument for that parameter, in
order to select a specific part of a date or indicate the date format used or desired (e.g.
RFC 822).
Using Constants
For example, the constant Zend_Date::HOUR can be used in the ways
shown below. When working with days of the week, calendar dates, hours, minutes,
seconds, and any other date parts that are expressed differently when in different parts
of the world, the object's timezone will automatically be used to compute the correct
value, even though the internal timestamp is the same for the same moment in time,
regardless of the user's physical location in the world. Regardless of the units
involved, output must be expressed either as GMT or
UTC or localized to a locale. The example output below reflects
localization to Europe/GMT+1 hour (e.g. Germany, Austria, France).
Operations Involving Zend_Date::HOUR
Method |
Description |
Original date |
Result |
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 |
List of All Constants
Each part of a date or time has a unique constant in Zend_Date.
All constants supported by Zend_Date are listed below.
Day Constants
Constant |
Description |
Date |
Result |
Zend_Date::DAY |
Day (as number, two digits) |
2009-02-13T14:53:27+01:00 |
13 |
Zend_Date::DAY_SHORT |
Day (as number, one or two digits) |
2009-02-06T14:53:27+01:00 |
6 |
Zend_Date::WEEKDAY |
Weekday (Name of the day, localized, complete) |
2009-02-13T14:53:27+01:00 |
Friday |
Zend_Date::WEEKDAY_SHORT |
Weekday (Name of the day, localized, abbreviated, two to four chars)
|
2009-02-13T14:53:27+01:00 |
Fri for Friday |
Zend_Date::WEEKDAY_NAME |
Weekday (Name of the day, localized, abbreviated, one or two chars)
|
2009-02-13T14:53:27+01:00 |
Fr for Friday |
Zend_Date::WEEKDAY_NARROW |
Weekday (Name of the day, localized, abbreviated, one char)
|
2009-02-13T14:53:27+01:00 |
F for Friday |
Zend_Date::WEEKDAY_DIGIT |
Weekday (0 = Sunday, 6 = Saturday) |
2009-02-13T14:53:27+01:00 |
5 for Friday |
Zend_Date::WEEKDAY_8601 |
Weekday according to ISO 8601 (1 = Monday, 7 =
Sunday)
|
2009-02-13T14:53:27+01:00 |
5 for Friday |
Zend_Date::DAY_OF_YEAR |
Day (as a number, one or two digits) |
2009-02-13T14:53:27+01:00 |
43
|
Zend_Date::DAY_SUFFIX |
English addendum for the day (st, nd, rd, th) |
2009-02-13T14:53:27+01:00 |
th |
Week Constants
Constant |
Description |
Date |
Result |
Zend_Date::WEEK |
Week (as number, 1-53) |
2009-02-13T14:53:27+01:00 |
8 |
Month Constants
Constant |
Description |
Date |
Result |
Zend_Date::MONTH_NAME |
Month (Name of the month, localized, complete) |
2009-02-13T14:53:27+01:00 |
February |
Zend_Date::MONTH_NAME_SHORT |
Month (Name of the month, localized, abbreviated, two to four chars)
|
2009-02-13T14:53:27+01:00 |
Feb |
Zend_Date::MONTH_NAME_NARROW |
Month (Name of the month, localized, abbreviated, one or two chars)
|
2009-02-13T14:53:27+01:00 |
F |
Zend_Date::MONTH |
Month (Number of the month, two digits) |
2009-02-13T14:53:27+01:00 |
02 |
Zend_Date::MONTH_SHORT |
Month (Number of the month, one or two digits) |
2009-02-13T14:53:27+01:00 |
2 |
Zend_Date::MONTH_DAYS |
Number of days for this month (number) |
2009-02-13T14:53:27+01:00 |
28 |
Year Constants
Constant |
Description |
Date |
Result |
Zend_Date::YEAR |
Year (number) |
2009-02-13T14:53:27+01:00 |
2009 |
Zend_Date::YEAR_8601 |
Year according to ISO 8601 (number) |
2009-02-13T14:53:27+01:00 |
2009 |
Zend_Date::YEAR_SHORT |
Year (number, two digits) |
2009-02-13T14:53:27+01:00 |
09 |
Zend_Date::YEAR_SHORT_8601 |
Year according to ISO 8601 (number, two digits)
|
2009-02-13T14:53:27+01:00 |
09 |
Zend_Date::LEAPYEAR |
Is the year a leap year? (TRUE or
FALSE)
|
2009-02-13T14:53:27+01:00 |
FALSE |
Time Constants
Constant |
Description |
Date |
Result |
Zend_Date::HOUR |
Hour (00-23, two digits) |
2009-02-13T14:53:27+01:00 |
14 |
Zend_Date::HOUR_SHORT |
Hour (0-23, one or two digits) |
2009-02-13T14:53:27+01:00 |
14 |
Zend_Date::HOUR_SHORT_AM |
Hour (1-12, one or two digits) |
2009-02-13T14:53:27+01:00 |
2 |
Zend_Date::HOUR_AM |
Hour (01-12, two digits) |
2009-02-13T14:53:27+01:00 |
02 |
Zend_Date::MINUTE |
Minute (00-59, two digits) |
2009-02-13T14:53:27+01:00 |
53 |
Zend_Date::MINUTE_SHORT |
Minute (0-59, one or two digits) |
2009-02-13T14:03:27+01:00 |
3 |
Zend_Date::SECOND |
Second (00-59, two digits) |
2009-02-13T14:53:27+01:00 |
27 |
Zend_Date::SECOND_SHORT |
Second (0-59, one or two digits) |
2009-02-13T14:53:07+01:00 |
7 |
Zend_Date::MILLISECOND |
Millisecond (theoretically infinite) |
2009-02-06T14:53:27.20546 |
20546 |
Zend_Date::MERIDIEM |
Time of day (forenoon or afternoon) |
2009-02-13T14:53:27+01:00 |
afternoon |
Zend_Date::SWATCH |
Swatch Internet Time |
2009-02-13T14:53:27+01:00 |
620 |
Timezone Constants
Constant |
Description |
Date |
Result |
Zend_Date::TIMEZONE |
Name der time zone (string, abbreviated) |
2009-02-13T14:53:27+01:00 |
CET |
Zend_Date::TIMEZONE_NAME |
Name of the time zone (string, complete) |
2009-02-13T14:53:27+01:00 |
Europe/Paris |
Zend_Date::TIMEZONE_SECS |
Difference of the time zone to GMT in seconds
(integer)
|
2009-02-13T14:53:27+01:00 |
3600 (seconds to GMT) |
Zend_Date::GMT_DIFF |
Difference to GMT in seconds (string) |
2009-02-13T14:53:27+01:00 |
+0100 |
Zend_Date::GMT_DIFF_SEP |
Difference to GMT in seconds (string, separated)
|
2009-02-13T14:53:27+01:00 |
+01:00 |
Zend_Date::DAYLIGHT |
Summer time or Winter time? (TRUE or
FALSE)
|
2009-02-13T14:53:27+01:00 |
FALSE |
Date Format Constants (formats include timezone)
Constant |
Description |
Date |
Result |
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 or HTTP according
to W3C (string)
|
2009-02-13T14:53:27+01:00 |
2009-02-13T14:53:27+01:00 |
Especially note Zend_Date::DATES, since this format specifier has
a unique property within Zend_Date as an
input format specifier. When used as an input format for
$part, this constant provides the most flexible acceptance of a
variety of similar date formats. Heuristics are used to automatically extract dates from
an input string and then "fix" simple errors in dates (if any), such as swapping of
years, months, and days, when possible.
Date and Time Formats (format varies by locale)
Constant |
Description |
Date |
Result |
Zend_Date::ERA |
Epoch (string, localized, abbreviated) |
2009-02-13T14:53:27+01:00 |
AD (anno Domini) |
Zend_Date::ERA_NAME |
Epoch (string, localized, complete) |
2009-02-13T14: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 |
Zend_Date::DATETIME |
Standard date with time (string, localized, default value). |
2009-02-13T14:53:27+01:00 |
13.02.2009 14:53:27 |
Zend_Date::DATETIME_FULL |
Complete date with time (string, localized, complete) |
2009-02-13T14:53:27+01:00 |
Friday, 13. February 2009 14:53 Uhr
CET
|
Zend_Date::DATETIME_LONG |
Long date with time (string, localized, long) |
2009-02-13T14:53:27+01:00 |
13. February 2009 14:53:27 CET
|
Zend_Date::DATETIME_MEDIUM |
Normal date with time (string, localized, normal) |
2009-02-13T14:53:27+01:00 |
13.02.2009 14:53:27 |
Zend_Date::DATETIME_SHORT |
Abbreviated date with time (string, localized, abbreviated) |
2009-02-13T14:53:27+01:00 |
13.02.09 14:53 |
|
|