1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.date.overview">
4 <title>Zend_Date API Overview</title>
7 While the <classname>Zend_Date</classname> <acronym>API</acronym> remains simplistic and
8 unitary, its design remains flexible and powerful through the rich permutations of
9 operations and operands.
12 <sect2 id="zend.date.options">
13 <title>Zend_Date Options</title>
15 <sect3 id="zend.date.options.formattype">
16 <title>Selecting the Date Format Type</title>
19 Several methods use date format strings, in a way similar to
20 <acronym>PHP</acronym>'s <methodname>date()</methodname>. If you are more
21 comfortable with <acronym>PHP</acronym>'s date format specifier than with
22 <acronym>ISO</acronym> format specifiers, then you can use
23 <methodname>Zend_Date::setOptions(array('format_type' => 'php'))</methodname>.
24 Afterward, use <acronym>PHP</acronym>'s date format specifiers for all functions
25 which accept a <varname>$format</varname> parameter. Use
26 <methodname>Zend_Date::setOptions(array('format_type' => 'iso'))</methodname> to
27 switch back to the default mode of supporting only <acronym>ISO</acronym> date
28 format tokens. For a list of supported format codes, see
29 <link linkend="zend.date.constants.phpformats">Self-Defined OUTPUT Formats
30 Using PHP's date() Format Specifiers</link>
34 <sect3 id="zend.date.options.fixdst">
35 <title>DST and Date Math</title>
38 When dates are manipulated, sometimes they cross over a <acronym>DST</acronym>
39 change, normally resulting in the date losing or gaining an hour. For exmaple, when
40 adding months to a date before a <acronym>DST</acronym> change, if the resulting
41 date is after the <acronym>DST</acronym> change, then the resulting date will appear
42 to lose or gain an hour, resulting in the time value of the date changing. For
43 boundary dates, such as midnight of the first or last day of a month, adding enough
44 months to cross a date boundary results in the date losing an hour and becoming the
45 last hour of the preceding month, giving the appearance of an "off by 1" error. To
46 avoid this situation, the <acronym>DST</acronym> change ignored by using the
47 <property>fix_dst</property> option. When crossing the Summer or Winter
48 <acronym>DST</acronym> boundary, normally an hour is substracted or added depending
49 on the date. For example, date math crossing the Spring <acronym>DST</acronym> leads
50 to a date having a day value one less than expected, if the time part of the date
51 was originally 00:00:00. Since <classname>Zend_Date</classname> is based on
52 timestamps, and not calendar dates with a time component, the timestamp loses an
53 hour, resulting in the date having a calendar day value one less than expected. To
54 prevent such problems use the option <property>fix_dst</property>, which defaults to
55 <constant>TRUE</constant>, causing <acronym>DST</acronym> to have no effect on date
56 "math" (<methodname>addMonth()</methodname>, <methodname>subMonth()</methodname>).
57 Use <methodname>Zend_Date::setOptions(array('fix_dst' => false))</methodname> to
58 enable the subtraction or addition of the <acronym>DST</acronym> adjustment when
59 performing date "math".
63 <emphasis>If your actual timezone within the instance of
64 <classname>Zend_Date</classname> is set to <acronym>UTC</acronym> or
65 <acronym>GMT</acronym> the option '<property>fix_dst</property>' will not be
66 used</emphasis> because these two timezones do not work with <acronym>DST</acronym>.
67 When you change the timezone for this instance again to a timezone which is not
68 <acronym>UTC</acronym> or <acronym>GMT</acronym> the previous set 'fix_dst' option
69 will be used again for date "math".
73 <sect3 id="zend.date.options.extendmonth">
74 <title>Month Calculations</title>
77 When adding or substracting months from an existing date, the resulting value for
78 the day of the month might be unexpected, if the original date fell on a day close
79 to the end of the month. For example, when adding one month to January 31st, people
80 familiar with <acronym>SQL</acronym> will expect February 28th as the result. On the
81 other side, people familiar with Excel and OpenOffice will expect March 3rd as the
82 result. The problem only occurs, if the resulting month does not have the day, which
83 is set in the original date. For Zend Framework developers, the desired behavior is
84 selectable using the <property>extend_month</property> option to choose either the
85 <acronym>SQL</acronym> behaviour, if set to <constant>FALSE</constant>, or the
86 spreadsheet behaviour when set to <constant>TRUE</constant>. The default behaviour
87 for <property>extend_month</property> is <constant>FALSE</constant>, providing
88 behavior compatible to <acronym>SQL</acronym>. By default,
89 <classname>Zend_Date</classname> computes month calculations by truncating dates to
90 the end of the month (if necessary), without wrapping into the next month when the
91 original date designates a day of the month exceeding the number of days in the
92 resulting month. Use <methodname>Zend_Date::setOptions(array('extend_month' =>
93 true))</methodname> to make month calculations work like popular spreadsheet
98 <sect3 id="zend.date.options.cache">
99 <title>Speed up Date Localization and Normalization with Zend_Cache</title>
102 You can speed up <classname>Zend_Date</classname> by using an
103 <classname>Zend_Cache</classname> adapter. This speeds up all methods of
104 <classname>Zend_Date</classname> when you are using localized data. For example all
105 methods which accept <constant>Zend_Date::DATE</constant> and
106 <constant>Zend_Date::TIME</constant> constants would benefit from this. To set an
107 <classname>Zend_Cache</classname> adapter to <classname>Zend_Date</classname> just
108 use <methodname>Zend_Date::setOptions(array('cache' => $adapter))</methodname>.
112 <sect3 id="zend.date.options.timesync">
113 <title>Receiving Syncronised Timestamps with Zend_TimeSync</title>
116 Normally the clocks from servers and computers differ from each other.
117 <classname>Zend_Date</classname> is able to handle such problems with the help of
118 <classname>Zend_TimeSync</classname>. You can set a timeserver with
119 <methodname>Zend_Date::setOptions(array('timesync' => $timeserver))</methodname>
120 which will set the offset between the own actual timestamp and the real actual
121 timestamp for all instances of <classname>Zend_Date</classname>. Using this option
122 does not change the timestamp of existing instances. So best usage is to set it
123 within the bootstrap file.
128 <sect2 id="zend.date.values">
129 <title>Working with Date Values</title>
132 Once input has been normalized via the creation of a <classname>Zend_Date</classname>
133 object, it will have an associated timezone, but an internal representation using
134 standard <ulink url="http://en.wikipedia.org/wiki/Unix_Time">UNIX timestamps</ulink>.
135 In order for a date to be rendered in a localized manner, a timezone must be known
136 first. The default timezone is always <acronym>GMT</acronym> or <acronym>UTC</acronym>.
137 To examine an object's timezone use <methodname>getTimeZone()</methodname>. To change an
138 object's timezone, use <methodname>setTimeZone()</methodname>. All manipulations of
139 these objects are assumed to be relative to this timezone.
143 Beware of mixing and matching operations with date parts between date objects for
144 different timezones, which generally produce undesireable results, unless the
145 manipulations are only related to the timestamp. Operating on
146 <classname>Zend_Date</classname> objects having different timezones generally works,
147 except as just noted, since dates are normalized to <acronym>UNIX</acronym> timestamps
148 on instantiation of <classname>Zend_Date</classname>.
152 Most methods expect a constant selecting the desired <varname>$part</varname> of a date,
153 such as <constant>Zend_Date::HOUR</constant>. These constants are valid for all of the
154 functions below. A list of all available constants is provided in
155 <link linkend="zend.date.constants.list">list of all constants</link>.
156 If no <varname>$part</varname> is
157 specified, then <constant>Zend_Date::TIMESTAMP</constant> is assumed. Alternatively, a
158 user-specified format may be used for <varname>$part</varname>, using the same
159 underlying mechanism and format codes as <link
160 linkend="zend.locale.date.normalize"><methodname>Zend_Locale_Format::getDate()</methodname></link>.
161 If a date object is constructed using an obviously invalid date (e.g. a month number
162 greater than 12), then <classname>Zend_Date</classname> will throw an exception, unless
163 no specific date format has been selected -i.e. <varname>$part</varname> is either
164 <constant>NULL</constant> or <constant>Zend_Date::DATES</constant> (a "loose" format).
167 <example id="zend.date.values.example-1">
168 <title>User-Specified Input Date Format</title>
170 <programlisting language="php"><![CDATA[
171 $date1 = new Zend_Date('Feb 31, 2007', null, 'en_US');
172 echo $date1, "\n"; // outputs "Mar 3, 2007 12:00:00 AM"
174 $date2 = new Zend_Date('Feb 31, 2007', Zend_Date::DATES, 'en_US');
175 echo $date2, "\n"; // outputs "Mar 3, 2007 12:00:00 AM"
177 // strictly restricts interpretation to specified format
178 $date3 = new Zend_Date('Feb 31, 2007', 'MM.dd.yyyy');
179 echo $date3, "\n"; // outputs "Mar 3, 2007 12:00:00 AM"
184 If the optional <varname>$locale</varname> parameter is provided, then the
185 <varname>$locale</varname> disambiguates the <varname>$date</varname> operand by
186 replacing month and weekday names for string <varname>$date</varname> operands, and even
187 parsing date strings expressed according to the conventions of that locale (see
188 <link linkend="zend.locale.date.normalize">Zend_Locale_Format::getDate()</link>).
189 The automatic normalization of localized <varname>$date</varname> operands of a
190 string type occurs when <varname>$part</varname> is one of the
191 <constant>Zend_Date::DATE</constant>* or <constant>Zend_Date::TIME</constant>*
192 constants. The locale identifies which language should be used to parse month names and
193 weekday names, if the <varname>$date</varname> is a string containing a date. If there
194 is no <varname>$date</varname> input parameter, then the <varname>$locale</varname>
195 parameter specifies the locale to use for localizing output (e.g. the date format for a
196 string representation). Note that the <varname>$date</varname> input parameter might
197 actually have a type name instead (e.g. <varname>$hour</varname> for
198 <methodname>addHour()</methodname>), although that does not prevent the use of
199 <classname>Zend_Date</classname> objects as arguments for that parameter. If no
200 <varname>$locale</varname> was specified, then the locale of the current object is used
201 to interpret <varname>$date</varname>, or select the localized format for output.
205 Since Zend Framework 1.7.0 <classname>Zend_Date</classname> does also support the usage
206 of an application wide locale. You can simply set a <classname>Zend_Locale</classname>
207 instance to the registry like shown below. With this notation you can forget about
208 setting the locale manually with each instance when you want to use the same locale
212 <programlisting language="php"><![CDATA[
213 // in your bootstrap file
214 $locale = new Zend_Locale('de_AT');
215 Zend_Registry::set('Zend_Locale', $locale);
217 // somewhere in your application
218 $date = new Zend_Date('31.Feb.2007');
222 <sect2 id="id.date.basic">
223 <title>Basic Zend_Date Operations Common to Many Date Parts</title>
226 The methods <methodname>add()</methodname>, <methodname>sub()</methodname>,
227 <methodname>compare()</methodname>, <methodname>get()</methodname>, and
228 <methodname>set()</methodname> operate generically on dates. In each case, the
229 operation is performed on the date held in the instance object. The
230 <varname>$date</varname> operand is required for all of these methods, except
231 <methodname>get()</methodname>, and may be a <classname>Zend_Date</classname> instance
232 object, a numeric string, or an integer. These methods assume <varname>$date</varname>
233 is a timestamp, if it is not an object. However, the <varname>$part</varname> operand
234 controls which logical part of the two dates are operated on, allowing operations on
235 parts of the object's date, such as year or minute, even when <varname>$date</varname>
236 contains a long form date string, such as, "December 31, 2007 23:59:59". The result of
237 the operation changes the date in the object, except for
238 <methodname>compare()</methodname>, and <methodname>get()</methodname>.
241 <example id="zend.date.basic.example-1">
242 <title>Operating on Parts of Dates</title>
244 <programlisting language="php"><![CDATA[
245 $date = new Zend_Date(); // $date's timestamp === time()
247 // changes $date by adding 12 hours
248 $date->add('12', Zend_Date::HOUR);
254 Convenience methods exist for each combination of the basic operations and several
255 common date parts as shown in the tables below. These convenience methods help us lazy
256 programmers avoid having to type out the <link linkend="zend.date.constants.list">date
257 part constants</link> when using the general methods above. Conveniently, they are
258 named by combining a prefix (name of a basic operation) with a suffix (type of date
259 part), such as <methodname>addYear()</methodname>. In the list below, all combinations
260 of "Date Parts" and "Basic Operations" exist. For example, the operation "add" exists
261 for each of these date parts, including <methodname>addDay()</methodname>,
262 <methodname>addYear()</methodname>, etc.
266 These convenience methods have the same equivalent functionality as the basic operation
267 methods, but expect string and integer <varname>$date</varname> operands containing only
268 the values representing the type indicated by the suffix of the convenience method.
269 Thus, the names of these methods (e.g. "Year" or "Minute") identify the units of the
270 <varname>$date</varname> operand, when <varname>$date</varname> is a string or integer.
273 <sect3 id="id.date.basic.parts">
274 <title>List of Date Parts</title>
276 <table id="id.date.basic.parts.table">
277 <title>Date Parts</title>
282 <entry>Date Part</entry>
283 <entry>Explanation</entry>
291 url="http://en.wikipedia.org/wiki/Unix_Time">Timestamp</ulink>
295 UNIX timestamp, expressed in seconds elapsed since January 1st, 1970
296 00:00:00 <acronym>GMT</acronym>.
303 url="http://en.wikipedia.org/wiki/Gregorian_calendar">Year</ulink>
306 <entry>Gregorian calendar year (e.g. 2006)</entry>
312 url="http://en.wikipedia.org/wiki/Month#Julian_and_Gregorian_calendars">Month</ulink>
316 Gregorian calendar month (1-12, localized names supported)
323 url="http://en.wikipedia.org/wiki/24-hour_clock">24 hour
328 Hours of the day (0-23) denote the hours elapsed, since the start of
335 <ulink url="http://en.wikipedia.org/wiki/Minute">minute</ulink>
339 Minutes of the hour (0-59) denote minutes elapsed, since the start
346 <ulink url="http://en.wikipedia.org/wiki/Second">Second</ulink>
350 Seconds of the minute (0-59) denote the elapsed seconds, since the
358 url="http://en.wikipedia.org/wiki/Millisecond">millisecond</ulink>
362 Milliseconds denote thousandths of a second (0-999).
363 <classname>Zend_Date</classname> supports two additional methods
364 for working with time units smaller than seconds. By default,
365 <classname>Zend_Date</classname> instances use a precision
366 defaulting to milliseconds, as seen using
367 <methodname>getFractionalPrecision()</methodname>. To change the
369 <methodname>setFractionalPrecision($precision)</methodname>.
370 However, precision is limited practically to microseconds, since
371 <classname>Zend_Date</classname> uses <ulink
372 url="http://php.net/microtime">microtime()</ulink>.
378 <ulink url="http://en.wikipedia.org/wiki/Day">Day</ulink>
382 <constant>Zend_Date::DAY_SHORT</constant> is extracted from
383 <varname>$date</varname> if the <varname>$date</varname> operand is
384 an instance of <classname>Zend_Date</classname> or a numeric string.
385 Otherwise, an attempt is made to extract the day according to the
386 conventions documented for these constants:
387 <constant>Zend_Date::WEEKDAY_NARROW</constant>,
388 <constant>Zend_Date::WEEKDAY_NAME</constant>,
389 <constant>Zend_Date::WEEKDAY_SHORT</constant>,
390 <constant>Zend_Date::WEEKDAY</constant> (Gregorian calendar
397 <ulink url="http://en.wikipedia.org/wiki/Week">Week</ulink>
401 <constant>Zend_Date::WEEK</constant> is extracted from
402 <varname>$date</varname> if the <varname>$date</varname> operand is
403 an instance of <classname>Zend_Date</classname> or a numeric string.
404 Otherwise an exception is raised. (Gregorian calendar assumed)
412 <constant>Zend_Date::DAY_MEDIUM</constant> is extracted from
413 <varname>$date</varname> if the <varname>$date</varname> operand is
414 an instance of <classname>Zend_Date</classname>. Otherwise, an
415 attempt is made to normalize the <varname>$date</varname> string
416 into a <constant>Zend_Date::DATE_MEDIUM</constant> formatted date.
417 The format of <constant>Zend_Date::DAY_MEDIUM</constant> depends on
423 <entry>Weekday</entry>
426 Weekdays are represented numerically as 0 (for Sunday) through 6
427 (for Saturday). <constant>Zend_Date::WEEKDAY_DIGIT</constant> is
428 extracted from <varname>$date</varname>, if the
429 <varname>$date</varname> operand is an instance of
430 <classname>Zend_Date</classname> or a numeric string. Otherwise, an
431 attempt is made to extract the day according to the conventions
432 documented for these constants:
433 <constant>Zend_Date::WEEKDAY_NARROW</constant>,
434 <constant>Zend_Date::WEEKDAY_NAME</constant>,
435 <constant>Zend_Date::WEEKDAY_SHORT</constant>,
436 <constant>Zend_Date::WEEKDAY</constant> (Gregorian calendar
442 <entry>DayOfYear</entry>
445 In <classname>Zend_Date</classname>, the day of the year represents
446 the number of calendar days elapsed since the start of the year
447 (0-365). As with other units above, fractions are rounded down to
448 the nearest whole number. (Gregorian calendar assumed)
454 <ulink url="http://www.faqs.org/rfcs/rfc822.html">Arpa</ulink>
458 Arpa dates (i.e. <acronym>RFC</acronym> 822 formatted dates) are
459 supported. Output uses either a "GMT" or "Local differential
460 hours+min" format (see section 5 of <acronym>RFC</acronym> 822).
461 Before <acronym>PHP</acronym> 5.2.2, using the
462 <constant>DATE_RFC822</constant> constant with
463 <acronym>PHP</acronym> date functions sometimes produces <ulink
464 url="http://bugs.php.net/bug.php?id=40308">incorrect
465 results</ulink>. <classname>Zend_Date</classname>'s results are
466 correct. Example: Mon, 31 Dec 06 23:59:59 <acronym>GMT</acronym>
472 <ulink url="http://en.wikipedia.org/wiki/ISO_8601">Iso</ulink>
476 Only complete <acronym>ISO</acronym> 8601 dates are supported for
477 output. Example: 2009-02-14T00:31:30+01:00
485 <sect3 id="id.date.basic.operations">
486 <title>List of Date Operations</title>
489 The basic operations below can be used instead of the convenience operations for
490 specific date parts, if the
491 <link linkend="zend.date.constants.list">appropriate constant</link>
492 is used for the <varname>$part</varname> parameter.
495 <table id="id.date.basic.operations.table">
496 <title>Basic Operations</title>
501 <entry>Basic Operation</entry>
502 <entry>Explanation</entry>
508 <entry><methodname>get()</methodname></entry>
512 <emphasis><methodname>get($part = null, $locale =
513 null)</methodname></emphasis>
517 Use <methodname>get($part)</methodname> to retrieve the date
518 <varname>$part</varname> of this object's date localized to
519 <varname>$locale</varname> as a formatted string or integer.
520 When using the BCMath extension, numeric strings might be
521 returned instead of integers for large values.
525 <title>Behaviour of get()</title>
528 Unlike <methodname>get()</methodname>, the other
529 get*() convenience methods only return instances of
530 <classname>Zend_Date</classname> containing a date
531 representing the selected or computed date or time.
538 <entry><methodname>set()</methodname></entry>
542 <emphasis><methodname>set($date, $part = null, $locale =
543 null)</methodname></emphasis>
547 Sets the <varname>$part</varname> of the current object to the
548 corresponding value for that part found in the input
549 <varname>$date</varname> having a locale
550 <varname>$locale</varname>.
556 <entry><methodname>add()</methodname></entry>
560 <emphasis><methodname>add($date, $part = null, $locale =
561 null)</methodname></emphasis>
565 Adds the <varname>$part</varname> of <varname>$date</varname>
566 having a locale <varname>$locale</varname> to the current
573 <entry><methodname>sub()</methodname></entry>
577 <emphasis><methodname>sub($date, $part = null, $locale =
578 null)</methodname></emphasis>
582 Subtracts the <varname>$part</varname> of
583 <varname>$date</varname> having a locale
584 <varname>$locale</varname> from the current object's date.
590 <entry><methodname>copyPart()</methodname></entry>
594 <emphasis><methodname>copyPart($part, $locale =
595 null)</methodname></emphasis>
599 Returns a cloned object, with only <varname>$part</varname> of
600 the object's date copied to the clone, with the clone have its
601 locale arbitrarily set to <varname>$locale</varname> (if
608 <entry><methodname>compare()</methodname></entry>
612 <emphasis><methodname>compare($date, $part = null, $locale =
613 null)</methodname></emphasis>
617 compares <varname>$part</varname> of <varname>$date</varname> to
618 this object's timestamp, returning 0 if they are equal, 1 if
619 this object's part was more recent than
620 <varname>$date</varname>'s part, otherwise -1.
630 <sect2 id="zend.date.others.comparison">
631 <title>Comparing Dates</title>
634 The following basic operations do not have corresponding convenience methods for the
635 date parts listed in <link linkend="zend.date.overview">Zend_Date API Overview</link>.
638 <table id="zend.date.others.comparison.table">
639 <title>Date Comparison Methods</title>
644 <entry>Method</entry>
645 <entry>Explanation</entry>
651 <entry><methodname>equals()</methodname></entry>
655 <emphasis><methodname>equals($date, $part = null, $locale =
656 null)</methodname></emphasis>
660 returns <constant>TRUE</constant>, if <varname>$part</varname> of
661 <varname>$date</varname> having locale <varname>$locale</varname> is
662 the same as this object's date <varname>$part</varname>, otherwise
663 <constant>FALSE</constant>
669 <entry><methodname>isEarlier()</methodname></entry>
673 <emphasis><methodname>isEarlier($date, $part = null, $locale =
674 null)</methodname></emphasis>
678 returns <constant>TRUE</constant>, if <varname>$part</varname> of
679 this object's date is earlier than <varname>$part</varname> of
680 <varname>$date</varname> having a locale <varname>$locale</varname>
686 <entry><methodname>isLater()</methodname></entry>
690 <emphasis><methodname>isLater($date, $part = null, $locale =
691 null)</methodname></emphasis>
695 returns <constant>TRUE</constant>, if <varname>$part</varname> of
696 this object's date is later than <varname>$part</varname> of
697 <varname>$date</varname> having a locale <varname>$locale</varname>
703 <entry><methodname>isToday()</methodname></entry>
707 <emphasis><methodname>isToday()</methodname></emphasis>
711 Tests if today's year, month, and day match this object's date
712 value, using this object's timezone.
718 <entry><methodname>isTomorrow()</methodname></entry>
722 <emphasis><methodname>isTomorrow()</methodname></emphasis>
726 Tests if tomorrow's year, month, and day match this object's date
727 value, using this object's timezone.
733 <entry><methodname>isYesterday()</methodname></entry>
737 <emphasis><methodname>isYesterday()</methodname></emphasis>
741 Tests if yesterday's year, month, and day match this object's date
742 value, using this object's timezone.
748 <entry><methodname>isLeapYear()</methodname></entry>
752 <emphasis><methodname>isLeapYear()</methodname></emphasis>
756 Use <methodname>isLeapYear()</methodname> to determine if the
757 current object is a leap year, or use
758 <methodname>Zend_Date::checkLeapYear($year)</methodname> to check
759 <varname>$year</varname>, which can be a string, integer, or
760 instance of <classname>Zend_Date</classname>. Is the year a leap
767 <entry><methodname>isDate()</methodname></entry>
771 <emphasis><methodname>isDate($date, $format = null, $locale =
772 null)</methodname></emphasis>
776 This method checks if a given date is a real date and returns
777 <constant>TRUE</constant> if all checks are ok. It works like
778 <acronym>PHP</acronym>'s <methodname>checkdate()</methodname>
779 function but can also check for localized month names and for dates
780 extending the range of <methodname>checkdate()</methodname>
789 <sect2 id="zend.date.others.gettingparts">
790 <title>Getting Dates and Date Parts</title>
793 Several methods support retrieving values related to a <classname>Zend_Date</classname>
797 <table id="zend.date.others.gettingparts.table">
798 <title>Date Output Methods</title>
803 <entry>Method</entry>
804 <entry>Explanation</entry>
810 <entry><methodname>toString()</methodname></entry>
814 <emphasis><methodname>toString($format = null, $locale =
815 null)</methodname></emphasis>
819 Invoke directly or via the magic method
820 <methodname>__toString()</methodname>. The
821 <methodname>toString()</methodname> method automatically formats
822 the date object's value according to the conventions of the
823 object's locale, or an optionally specified
824 <varname>$locale</varname>. For a list of supported format codes,
826 linkend="zend.date.constants.selfdefinedformats">Self-Defined
827 OUTPUT Formats with ISO</link>.
833 <entry><methodname>toArray()</methodname></entry>
837 <emphasis><methodname>toArray()</methodname></emphasis>
841 Returns an array representation of the selected date according to
842 the conventions of the object's locale. The returned array is
843 equivalent to <acronym>PHP</acronym>'s <ulink
844 url="http://php.net/getdate">getdate()</ulink> function and
851 Number of day as '<emphasis>day</emphasis>'
852 (<constant>Zend_Date::DAY_SHORT</constant>)
858 Number of month as '<emphasis>month</emphasis>'
859 (<constant>Zend_Date::MONTH_SHORT</constant>)
865 Year as '<emphasis>year</emphasis>'
866 (<constant>Zend_Date::YEAR</constant>)
872 Hour as '<emphasis>hour</emphasis>'
873 (<constant>Zend_Date::HOUR_SHORT</constant>)
879 Minute as '<emphasis>minute</emphasis>'
880 (<constant>Zend_Date::MINUTE_SHORT</constant>)
886 Second as '<emphasis>second</emphasis>'
887 (<constant>Zend_Date::SECOND_SHORT</constant>)
893 Abbreviated timezone as '<emphasis>timezone</emphasis>'
894 (<constant>Zend_Date::TIMEZONE</constant>)
900 Unix timestamp as '<emphasis>timestamp</emphasis>'
901 (<constant>Zend_Date::TIMESTAMP</constant>)
907 Number of weekday as '<emphasis>weekday</emphasis>'
908 (<constant>Zend_Date::WEEKDAY_DIGIT</constant>)
914 Day of year as '<emphasis>dayofyear</emphasis>'
915 (<constant>Zend_Date::DAY_OF_YEAR</constant>)
921 Week as '<emphasis>week</emphasis>'
922 (<constant>Zend_Date::WEEK</constant>)
928 Delay of timezone to <acronym>GMT</acronym> as
929 '<emphasis>gmtsecs</emphasis>'
930 (<constant>Zend_Date::GMT_SECS</constant>)
938 <entry><methodname>toValue()</methodname></entry>
942 <emphasis><methodname>toValue($part = null)</methodname></emphasis>
946 Returns an integer representation of the selected date
947 <varname>$part</varname> according to the conventions of the
948 object's locale. Returns <constant>FALSE</constant> when
949 <varname>$part</varname> selects a non-numeric value, such as
950 <constant>Zend_Date::MONTH_NAME_SHORT</constant>.
954 <title>Limitation of toValue()</title>
957 This method calls <link
958 linkend="id.date.basic.operations"><methodname>get()</methodname></link>
959 and casts the result to a <acronym>PHP</acronym> integer, which
960 will give unpredictable results, if
961 <methodname>get()</methodname> returns a numeric string
962 containing a number too large for a <acronym>PHP</acronym>
963 integer on your system. Use <methodname>get()</methodname>
972 <link linkend="id.date.basic.operations">get()</link>
977 <emphasis><methodname>get($part = null, $locale =
978 null)</methodname></emphasis>
982 This method returns the <varname>$part</varname> of object's date
983 localized to <varname>$locale</varname> as a formatted string or
984 integer. See <link linkend="id.date.basic.operations">get()</link>
985 for more information.
991 <entry><methodname>now()</methodname></entry>
995 <emphasis><methodname>now($locale = null)</methodname></emphasis>
999 This convenience function is equivalent to <command>new
1000 Zend_Date()</command>. It returns the current date as a
1001 <classname>Zend_Date</classname> object, having
1002 <varname>$locale</varname>
1011 <sect2 id="zend.date.others.fractions">
1012 <title>Working with Fractions of Seconds</title>
1015 Several methods support retrieving values related to a <classname>Zend_Date</classname>
1019 <table id="zend.date.others.fractions.table">
1020 <title>Date Output Methods</title>
1025 <entry>Method</entry>
1026 <entry>Explanation</entry>
1034 <emphasis><methodname>getFractionalPrecision()</methodname></emphasis>
1038 <entry>Return the precision of the part seconds</entry>
1044 <emphasis><methodname>setFractionalPrecision()</methodname></emphasis>
1048 <entry>Set the precision of the part seconds</entry>
1055 <sect2 id="zend.date.other.sun">
1056 <title>Sunrise / Sunset</title>
1059 Three methods provide access to geographically localized information about the Sun,
1060 including the time of sunrise and sunset.
1063 <table id="zend.date.other.sun.table">
1064 <title>Miscellaneous Methods</title>
1069 <entry>Method</entry>
1070 <entry>Explanation</entry>
1078 <emphasis><methodname>getSunrise($location)</methodname></emphasis>
1082 <entry>Return the date's time of sunrise</entry>
1088 <emphasis><methodname>getSunset($location)</methodname></emphasis>
1092 <entry>Return the date's time of sunset</entry>
1098 <emphasis><methodname>getSunInfo($location)</methodname></emphasis>
1102 <entry>Return an array with the date's sun dates</entry>
1110 vim:se ts=4 sw=4 et: