| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <sect1 id="zend.date.constants">
- <title>Constants for General Date Functions</title>
- <para>
- Whenever a <classname>Zend_Date</classname> method has a <varname>$parts</varname>
- 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.
- <acronym>RFC</acronym> 822).
- </para>
- <sect2 id="zend.date.constants.using">
- <title>Using Constants</title>
- <para>
- For example, the constant <constant>Zend_Date::HOUR</constant> 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 <acronym>GMT</acronym> or
- <acronym>UTC</acronym> or localized to a locale. The example output below reflects
- localization to Europe/GMT+1 hour (e.g. Germany, Austria, France).
- </para>
- <table id="zend.date.constants.using.table">
- <title>Operations Involving Zend_Date::HOUR</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>Method</entry>
- <entry>Description</entry>
- <entry>Original date</entry>
- <entry>Result</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><methodname>get(Zend_Date::HOUR)</methodname></entry>
- <entry>Output of the hour</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry>14</entry>
- </row>
- <row>
- <entry><methodname>set(12, Zend_Date::HOUR)</methodname></entry>
- <entry>Set new hour</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry>2009-02-13T12:53:27+01:00</entry>
- </row>
- <row>
- <entry><methodname>add(12, Zend_Date::HOUR)</methodname></entry>
- <entry>Add hours</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry>2009-02-14T02:53:27+01:00</entry>
- </row>
- <row>
- <entry><methodname>sub(12, Zend_Date::HOUR)</methodname></entry>
- <entry>Subtract hours</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry>2009-02-13T02:53:27+01:00</entry>
- </row>
- <row>
- <entry><methodname>compare(12, Zend_Date::HOUR)</methodname></entry>
- <entry>Compare hour, returns 0, 1 or -1</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry>1 (if object > argument)</entry>
- </row>
- <row>
- <entry><methodname>copy(Zend_Date::HOUR)</methodname></entry>
- <entry>Copies only the hour part</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry>1970-01-01T14:00:00+01:00</entry>
- </row>
- <row>
- <entry><methodname>equals(14, Zend_Date::HOUR)</methodname></entry>
- <entry>Compares the hour, returns <constant>TRUE</constant> or
- <constant>FALSE</constant></entry> <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><constant>TRUE</constant></entry>
- </row>
- <row>
- <entry><methodname>isEarlier(12, Zend_Date::HOUR)</methodname></entry>
- <entry>Compares the hour, returns <constant>TRUE</constant> or
- <constant>FALSE</constant></entry> <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><constant>TRUE</constant></entry>
- </row>
- <row>
- <entry><methodname>isLater(12, Zend_Date::HOUR)</methodname></entry>
- <entry>Compares the hour, returns <constant>TRUE</constant> or
- <constant>FALSE</constant></entry> <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><constant>FALSE</constant></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </sect2>
- <sect2 id="zend.date.constants.list">
- <title>List of All Constants</title>
- <para>
- Each part of a date or time has a unique constant in <classname>Zend_Date</classname>.
- All constants supported by <classname>Zend_Date</classname> are listed below.
- </para>
- <table id="zend.date.constants.list.table-1">
- <title>Day Constants</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>Constant</entry>
- <entry>Description</entry>
- <entry>Date</entry>
- <entry>Result</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>Zend_Date::DAY</constant></entry>
- <entry>Day (as number, two digits)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>13</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DAY_SHORT</constant></entry>
- <entry>Day (as number, one or two digits)</entry>
- <entry>2009-02-06T14:53:27+01:00</entry>
- <entry><emphasis>6</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::WEEKDAY</constant></entry>
- <entry>Weekday (Name of the day, localized, complete)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>Friday</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::WEEKDAY_SHORT</constant></entry>
- <entry>
- Weekday (Name of the day, localized, abbreviated, two to four chars)
- </entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>Fri</emphasis> for Friday</entry>
- </row>
- <row>
- <entry><constant>Zend_Date::WEEKDAY_NAME</constant></entry>
- <entry>
- Weekday (Name of the day, localized, abbreviated, one or two chars)
- </entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>Fr</emphasis> for Friday</entry>
- </row>
- <row>
- <entry><constant>Zend_Date::WEEKDAY_NARROW</constant></entry>
- <entry>
- Weekday (Name of the day, localized, abbreviated, one char)
- </entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>F</emphasis> for Friday</entry>
- </row>
- <row>
- <entry><constant>Zend_Date::WEEKDAY_DIGIT</constant></entry>
- <entry>Weekday (0 = Sunday, 6 = Saturday)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>5</emphasis> for Friday</entry>
- </row>
- <row>
- <entry><constant>Zend_Date::WEEKDAY_8601</constant></entry>
- <entry>
- Weekday according to <acronym>ISO</acronym> 8601 (1 = Monday, 7 =
- Sunday)
- </entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>5</emphasis> for Friday</entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DAY_OF_YEAR</constant></entry>
- <entry>Day (as a number, one or two digits)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>43</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DAY_SUFFIX</constant></entry>
- <entry>English addendum for the day (st, nd, rd, th)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>th</emphasis></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table id="zend.date.constants.list.table-2">
- <title>Week Constants</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>Constant</entry>
- <entry>Description</entry>
- <entry>Date</entry>
- <entry>Result</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>Zend_Date::WEEK</constant></entry>
- <entry>Week (as number, 1-53)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>8</emphasis></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table id="zend.date.constants.list.table-3">
- <title>Month Constants</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>Constant</entry>
- <entry>Description</entry>
- <entry>Date</entry>
- <entry>Result</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>Zend_Date::MONTH_NAME</constant></entry>
- <entry>Month (Name of the month, localized, complete)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>February</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::MONTH_NAME_SHORT</constant></entry>
- <entry>
- Month (Name of the month, localized, abbreviated, two to four chars)
- </entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>Feb</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::MONTH_NAME_NARROW</constant></entry>
- <entry>
- Month (Name of the month, localized, abbreviated, one or two chars)
- </entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>F</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::MONTH</constant></entry>
- <entry>Month (Number of the month, two digits)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>02</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::MONTH_SHORT</constant></entry>
- <entry>Month (Number of the month, one or two digits)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>2</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::MONTH_DAYS</constant></entry>
- <entry>Number of days for this month (number)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>28</emphasis></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table id="zend.date.constants.list.table-4">
- <title>Year Constants</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>Constant</entry>
- <entry>Description</entry>
- <entry>Date</entry>
- <entry>Result</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>Zend_Date::YEAR</constant></entry>
- <entry>Year (number)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>2009</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::YEAR_8601</constant></entry>
- <entry>Year according to <acronym>ISO</acronym> 8601 (number)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>2009</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::YEAR_SHORT</constant></entry>
- <entry>Year (number, two digits)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>09</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::YEAR_SHORT_8601</constant></entry>
- <entry>
- Year according to <acronym>ISO</acronym> 8601 (number, two digits)
- </entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>09</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::LEAPYEAR</constant></entry>
- <entry>
- Is the year a leap year? (<constant>TRUE</constant> or
- <constant>FALSE</constant>)
- </entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><constant>FALSE</constant></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table id="zend.date.constants.list.table-5">
- <title>Time Constants</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>Constant</entry>
- <entry>Description</entry>
- <entry>Date</entry>
- <entry>Result</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>Zend_Date::HOUR</constant></entry>
- <entry>Hour (00-23, two digits)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>14</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::HOUR_SHORT</constant></entry>
- <entry>Hour (0-23, one or two digits)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>14</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::HOUR_SHORT_AM</constant></entry>
- <entry>Hour (1-12, one or two digits)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>2</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::HOUR_AM</constant></entry>
- <entry>Hour (01-12, two digits)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>02</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::MINUTE</constant></entry>
- <entry>Minute (00-59, two digits)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>53</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::MINUTE_SHORT</constant></entry>
- <entry>Minute (0-59, one or two digits)</entry>
- <entry>2009-02-13T14:03:27+01:00</entry>
- <entry><emphasis>3</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::SECOND</constant></entry>
- <entry>Second (00-59, two digits)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>27</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::SECOND_SHORT</constant></entry>
- <entry>Second (0-59, one or two digits)</entry>
- <entry>2009-02-13T14:53:07+01:00</entry>
- <entry><emphasis>7</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::MILLISECOND</constant></entry>
- <entry>Millisecond (theoretically infinite)</entry>
- <entry><command>2009-02-06T14:53:27.20546</command></entry>
- <entry><emphasis>20546</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::MERIDIEM</constant></entry>
- <entry>Time of day (forenoon or afternoon)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>afternoon</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::SWATCH</constant></entry>
- <entry>Swatch Internet Time</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>620</emphasis></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table id="zend.date.constants.list.table-6">
- <title>Timezone Constants</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>Constant</entry>
- <entry>Description</entry>
- <entry>Date</entry>
- <entry>Result</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>Zend_Date::TIMEZONE</constant></entry>
- <entry>Name der time zone (string, abbreviated)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis><acronym>CET</acronym></emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::TIMEZONE_NAME</constant></entry>
- <entry>Name of the time zone (string, complete)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis><command>Europe/Paris</command></emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::TIMEZONE_SECS</constant></entry>
- <entry>
- Difference of the time zone to <acronym>GMT</acronym> in seconds
- (integer)
- </entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>3600</emphasis> (seconds to <acronym>GMT</acronym>)</entry>
- </row>
- <row>
- <entry><constant>Zend_Date::GMT_DIFF</constant></entry>
- <entry>Difference to <acronym>GMT</acronym> in seconds (string)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>+0100</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::GMT_DIFF_SEP</constant></entry>
- <entry>
- Difference to <acronym>GMT</acronym> in seconds (string, separated)
- </entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>+01:00</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DAYLIGHT</constant></entry>
- <entry>
- Summer time or Winter time? (<constant>TRUE</constant> or
- <constant>FALSE</constant>)
- </entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><constant>FALSE</constant></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table id="zend.date.constants.list.table-7">
- <title>Date Format Constants (formats include timezone)</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>Constant</entry>
- <entry>Description</entry>
- <entry>Date</entry>
- <entry>Result</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>Zend_Date::ISO_8601</constant></entry>
- <entry>
- Date according to <acronym>ISO</acronym> 8601 (string, complete)
- </entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>2009-02-13T14:53:27+01:00</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::RFC_2822</constant></entry>
- <entry>Date according to <acronym>RFC</acronym> 2822 (string)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>Fri, 13 Feb 2009 14:53:27 +0100</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::TIMESTAMP</constant></entry>
- <entry>
- <ulink url="http://en.wikipedia.org/wiki/Unix_Time">Unix time</ulink>
- (seconds since 1.1.1970, mixed)
- </entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>1234533207</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::ATOM</constant></entry>
- <entry>Date according to <acronym>ATOM</acronym> (string)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>2009-02-13T14:53:27+01:00</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::COOKIE</constant></entry>
- <entry>Date for Cookies (string, for Cookies)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry>
- <emphasis><command>Friday, 13-Feb-09 14:53:27
- Europe/Paris</command></emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>Zend_Date::RFC_822</constant></entry>
- <entry>Date according to <acronym>RFC</acronym> 822 (string)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>Fri, 13 Feb 09 14:53:27 +0100</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::RFC_850</constant></entry>
- <entry>Date according to <acronym>RFC</acronym> 850 (string)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry>
- <emphasis><command>Friday, 13-Feb-09 14:53:27
- Europe/Paris</command></emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>Zend_Date::RFC_1036</constant></entry>
- <entry>Date according to <acronym>RFC</acronym> 1036 (string)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>Fri, 13 Feb 09 14:53:27 +0100</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::RFC_1123</constant></entry>
- <entry>Date according to <acronym>RFC</acronym> 1123 (string)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>Fri, 13 Feb 2009 14:53:27 +0100</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::RFC_3339</constant></entry>
- <entry>Date according to <acronym>RFC</acronym> 3339 (string)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>2009-02-13T14:53:27+01:00</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::RSS</constant></entry>
- <entry>Date for <acronym>RSS</acronym> Feeds (string)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>Fri, 13 Feb 2009 14:53:27 +0100</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::W3C</constant></entry>
- <entry>
- Date for <acronym>HTML</acronym> or <acronym>HTTP</acronym> according
- to <acronym>W3C</acronym> (string)
- </entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>2009-02-13T14:53:27+01:00</emphasis></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>
- Especially note <constant>Zend_Date::DATES</constant>, since this format specifier has
- a unique property within <classname>Zend_Date</classname> as an
- <emphasis>input</emphasis> format specifier. When used as an input format for
- <varname>$part</varname>, 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.
- </para>
- <table id="zend.date.constants.list.table-8">
- <title>Date and Time Formats (format varies by locale)</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>Constant</entry>
- <entry>Description</entry>
- <entry>Date</entry>
- <entry>Result</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>Zend_Date::ERA</constant></entry>
- <entry>Epoch (string, localized, abbreviated)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>AD</emphasis> (anno Domini)</entry>
- </row>
- <row>
- <entry><constant>Zend_Date::ERA_NAME</constant></entry>
- <entry>Epoch (string, localized, complete)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>anno domini</emphasis> (anno Domini)</entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DATES</constant></entry>
- <entry>Standard date (string, localized, default value).</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>13.02.2009</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DATE_FULL</constant></entry>
- <entry>Complete date (string, localized, complete)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>Friday, 13. February 2009</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DATE_LONG</constant></entry>
- <entry>Long date (string, localized, long)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>13. February 2009</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DATE_MEDIUM</constant></entry>
- <entry>Normal date (string, localized, normal)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>13.02.2009</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DATE_SHORT</constant></entry>
- <entry>Abbreviated Date (string, localized, abbreviated)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>13.02.09</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::TIMES</constant></entry>
- <entry>Standard time (string, localized, default value)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>14:53:27</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::TIME_FULL</constant></entry>
- <entry>Complete time (string, localized, complete)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis><command>14:53 Uhr CET</command></emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::TIME_LONG</constant></entry>
- <entry>Long time (string, localized, Long)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis><command>14:53:27 CET</command></emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::TIME_MEDIUM</constant></entry>
- <entry>Normal time (string, localized, normal)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>14:53:27</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::TIME_SHORT</constant></entry>
- <entry>Abbreviated time (string, localized, abbreviated)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>14:53</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DATETIME</constant></entry>
- <entry>Standard date with time (string, localized, default value).</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>13.02.2009 14:53:27</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DATETIME_FULL</constant></entry>
- <entry>Complete date with time (string, localized, complete)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry>
- <emphasis><command>Friday, 13. February 2009 14:53 Uhr
- CET</command></emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DATETIME_LONG</constant></entry>
- <entry>Long date with time (string, localized, long)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry>
- <emphasis><command>13. February 2009 14:53:27 CET</command></emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DATETIME_MEDIUM</constant></entry>
- <entry>Normal date with time (string, localized, normal)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>13.02.2009 14:53:27</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DATETIME_SHORT</constant></entry>
- <entry>Abbreviated date with time (string, localized, abbreviated)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>13.02.09 14:53</emphasis></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </sect2>
- <sect2 id="zend.date.constants.selfdefinedformats">
- <title>Self-Defined OUTPUT Formats with ISO</title>
- <para>
- If you need a date format not shown above, then use a self-defined format composed from
- the <acronym>ISO</acronym> format token specifiers below. The following examples
- illustrate the usage of constants from the table below to create self-defined
- <acronym>ISO</acronym> formats. The format length is unlimited. Also, multiple usage of
- format constants is allowed.
- </para>
- <para>
- The accepted format specifiers can be changed from <acronym>ISO</acronym> Format to
- <acronym>PHP</acronym>'s date format if you are more comfortable with it. However, not
- all formats defined in the <acronym>ISO</acronym> norm are supported with
- <acronym>PHP</acronym>'s date format specifiers. Use the
- <methodname>Zend_Date::setOptions(array('format_type' => 'php'))</methodname> method to
- switch <classname>Zend_Date</classname> methods from supporting <acronym>ISO</acronym>
- format specifiers to <acronym>PHP</acronym> <methodname>date()</methodname> type
- specifiers (see <link linkend="zend.date.constants.phpformats">Self-Defined OUTPUT
- Formats Using PHP's date() Format Specifiers</link> below).
- </para>
- <example id="zend.date.constants.selfdefinedformats.example-1">
- <title>Self-Defined ISO Formats</title>
- <programlisting language="php"><![CDATA[
- $locale = new Zend_Locale('de_AT');
- $date = new Zend_Date(1234567890, false, $locale);
- print $date->toString("'Era:GGGG='GGGG, ' Date:yy.MMMM.dd'yy.MMMM.dd");
- ]]></programlisting>
- </example>
- <table id="zend.date.constants.selfdefinedformats.table">
- <title>Constants for ISO 8601 Date Output</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>Constant</entry>
- <entry>Description</entry>
- <entry>Corresponds best to</entry>
- <entry>Result</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>G</entry>
- <entry>Epoch, localized, abbreviated</entry>
- <entry><constant>Zend_Date::ERA</constant></entry>
- <entry><emphasis>AD</emphasis></entry>
- </row>
- <row>
- <entry>GG</entry>
- <entry>Epoch, localized, abbreviated</entry>
- <entry><constant>Zend_Date::ERA</constant></entry>
- <entry><emphasis>AD</emphasis></entry>
- </row>
- <row>
- <entry><constant>GGG</constant></entry>
- <entry>Epoch, localized, abbreviated</entry>
- <entry><constant>Zend_Date::ERA</constant></entry>
- <entry><emphasis>AD</emphasis></entry>
- </row>
- <row>
- <entry><constant>GGGG</constant></entry>
- <entry>Epoch, localized, complete</entry>
- <entry><constant>Zend_Date::ERA_NAME</constant></entry>
- <entry><emphasis>anno domini</emphasis></entry>
- </row>
- <row>
- <entry><constant>GGGGG</constant></entry>
- <entry>Epoch, localized, abbreviated</entry>
- <entry><constant>Zend_Date::ERA</constant></entry>
- <entry><emphasis>a</emphasis></entry>
- </row>
- <row>
- <entry>y</entry>
- <entry>Year, at least one digit</entry>
- <entry><constant>Zend_Date::YEAR</constant></entry>
- <entry><emphasis>9</emphasis></entry>
- </row>
- <row>
- <entry>yy</entry>
- <entry>Year, at least two digit</entry>
- <entry><constant>Zend_Date::YEAR_SHORT</constant></entry>
- <entry><emphasis>09</emphasis></entry>
- </row>
- <row>
- <entry>yyy</entry>
- <entry>Year, at least three digit</entry>
- <entry><constant>Zend_Date::YEAR</constant></entry>
- <entry><emphasis>2009</emphasis></entry>
- </row>
- <row>
- <entry>yyyy</entry>
- <entry>Year, at least four digit</entry>
- <entry><constant>Zend_Date::YEAR</constant></entry>
- <entry><emphasis>2009</emphasis></entry>
- </row>
- <row>
- <entry>yyyyy</entry>
- <entry>Year, at least five digit</entry>
- <entry><constant>Zend_Date::YEAR</constant></entry>
- <entry><emphasis>02009</emphasis></entry>
- </row>
- <row>
- <entry>Y</entry>
- <entry>
- Year according to <acronym>ISO</acronym> 8601, at least one digit
- </entry>
- <entry><constant>Zend_Date::YEAR_8601</constant></entry>
- <entry><emphasis>9</emphasis></entry>
- </row>
- <row>
- <entry>YY</entry>
- <entry>
- Year according to <acronym>ISO</acronym> 8601, at least two digit
- </entry>
- <entry><constant>Zend_Date::YEAR_SHORT_8601</constant></entry>
- <entry><emphasis>09</emphasis></entry>
- </row>
- <row>
- <entry><constant>YYY</constant></entry>
- <entry>
- Year according to <acronym>ISO</acronym> 8601, at least three digit
- </entry>
- <entry><constant>Zend_Date::YEAR_8601</constant></entry>
- <entry><emphasis>2009</emphasis></entry>
- </row>
- <row>
- <entry><constant>YYYY</constant></entry>
- <entry>
- Year according to <acronym>ISO</acronym> 8601, at least four digit
- </entry>
- <entry><constant>Zend_Date::YEAR_8601</constant></entry>
- <entry><emphasis>2009</emphasis></entry>
- </row>
- <row>
- <entry><constant>YYYYY</constant></entry>
- <entry>
- Year according to <acronym>ISO</acronym> 8601, at least five digit
- </entry>
- <entry><constant>Zend_Date::YEAR_8601</constant></entry>
- <entry><emphasis>02009</emphasis></entry>
- </row>
- <row>
- <entry>M</entry>
- <entry>Month, one or two digit</entry>
- <entry><constant>Zend_Date::MONTH_SHORT</constant></entry>
- <entry><emphasis>2</emphasis></entry>
- </row>
- <row>
- <entry>MM</entry>
- <entry>Month, two digit</entry>
- <entry><constant>Zend_Date::MONTH</constant></entry>
- <entry><emphasis>02</emphasis></entry>
- </row>
- <row>
- <entry><constant>MMM</constant></entry>
- <entry>Month, localized, abbreviated</entry>
- <entry><constant>Zend_Date::MONTH_NAME_SHORT</constant></entry>
- <entry><emphasis>Feb</emphasis></entry>
- </row>
- <row>
- <entry><constant>MMMM</constant></entry>
- <entry>Month, localized, complete</entry>
- <entry><constant>Zend_Date::MONTH_NAME</constant></entry>
- <entry><emphasis>February</emphasis></entry>
- </row>
- <row>
- <entry><constant>MMMMM</constant></entry>
- <entry>Month, localized, abbreviated, one digit</entry>
- <entry><constant>Zend_Date::MONTH_NAME_NARROW</constant></entry>
- <entry><emphasis>F</emphasis></entry>
- </row>
- <row>
- <entry>w</entry>
- <entry>Week, one or two digit</entry>
- <entry><constant>Zend_Date::WEEK</constant></entry>
- <entry><emphasis>5</emphasis></entry>
- </row>
- <row>
- <entry>ww</entry>
- <entry>Week, two digit</entry>
- <entry><constant>Zend_Date::WEEK</constant></entry>
- <entry><emphasis>05</emphasis></entry>
- </row>
- <row>
- <entry>d</entry>
- <entry>Day of the month, one or two digit</entry>
- <entry><constant>Zend_Date::DAY_SHORT</constant></entry>
- <entry><emphasis>9</emphasis></entry>
- </row>
- <row>
- <entry>dd</entry>
- <entry>Day of the month, two digit</entry>
- <entry><constant>Zend_Date::DAY</constant></entry>
- <entry><emphasis>09</emphasis></entry>
- </row>
- <row>
- <entry>D</entry>
- <entry>Day of the year, one, two or three digit</entry>
- <entry><constant>Zend_Date::DAY_OF_YEAR</constant></entry>
- <entry><emphasis>7</emphasis></entry>
- </row>
- <row>
- <entry>DD</entry>
- <entry>Day of the year, two or three digit</entry>
- <entry><constant>Zend_Date::DAY_OF_YEAR</constant></entry>
- <entry><emphasis>07</emphasis></entry>
- </row>
- <row>
- <entry><constant>DDD</constant></entry>
- <entry>Day of the year, three digit</entry>
- <entry><constant>Zend_Date::DAY_OF_YEAR</constant></entry>
- <entry><emphasis>007</emphasis></entry>
- </row>
- <row>
- <entry>E</entry>
- <entry>Day of the week, localized, abbreviated, one char</entry>
- <entry><constant>Zend_Date::WEEKDAY_NARROW</constant></entry>
- <entry><emphasis>M</emphasis></entry>
- </row>
- <row>
- <entry>EE</entry>
- <entry>Day of the week, localized, abbreviated, two or more chars</entry>
- <entry><constant>Zend_Date::WEEKDAY_NAME</constant></entry>
- <entry><emphasis>Mo</emphasis></entry>
- </row>
- <row>
- <entry><constant>EEE</constant></entry>
- <entry>Day of the week, localized, abbreviated, three chars</entry>
- <entry><constant>Zend_Date::WEEKDAY_SHORT</constant></entry>
- <entry><emphasis>Mon</emphasis></entry>
- </row>
- <row>
- <entry><constant>EEEE</constant></entry>
- <entry>Day of the week, localized, complete</entry>
- <entry><constant>Zend_Date::WEEKDAY</constant></entry>
- <entry><emphasis>Monday</emphasis></entry>
- </row>
- <row>
- <entry><constant>EEEEE</constant></entry>
- <entry>Day of the week, localized, abbreviated, one digit</entry>
- <entry><constant>Zend_Date::WEEKDAY_NARROW</constant></entry>
- <entry><emphasis>M</emphasis></entry>
- </row>
- <row>
- <entry>e</entry>
- <entry>Number of the day, one digit</entry>
- <entry><constant>Zend_Date::WEEKDAY_DIGIT</constant></entry>
- <entry><emphasis>4</emphasis></entry>
- </row>
- <row>
- <entry>ee</entry>
- <entry>Number of the day, two digit</entry>
- <entry><constant>Zend_Date::WEEKDAY_NARROW</constant></entry>
- <entry><emphasis>04</emphasis></entry>
- </row>
- <row>
- <entry>a</entry>
- <entry>Time of day, localized</entry>
- <entry><constant>Zend_Date::MERIDIEM</constant></entry>
- <entry><emphasis>vorm.</emphasis></entry>
- </row>
- <row>
- <entry>h</entry>
- <entry>Hour, (1-12), one or two digit</entry>
- <entry><constant>Zend_Date::HOUR_SHORT_AM</constant></entry>
- <entry><emphasis>2</emphasis></entry>
- </row>
- <row>
- <entry>hh</entry>
- <entry>Hour, (01-12), two digit</entry>
- <entry><constant>Zend_Date::HOUR_AM</constant></entry>
- <entry><emphasis>02</emphasis></entry>
- </row>
- <row>
- <entry>H</entry>
- <entry>Hour, (0-23), one or two digit</entry>
- <entry><constant>Zend_Date::HOUR_SHORT</constant></entry>
- <entry><emphasis>2</emphasis></entry>
- </row>
- <row>
- <entry>HH</entry>
- <entry>Hour, (00-23), two digit</entry>
- <entry><constant>Zend_Date::HOUR</constant></entry>
- <entry><emphasis>02</emphasis></entry>
- </row>
- <row>
- <entry>m</entry>
- <entry>Minute, (0-59), one or two digit</entry>
- <entry><constant>Zend_Date::MINUTE_SHORT</constant></entry>
- <entry><emphasis>2</emphasis></entry>
- </row>
- <row>
- <entry>mm</entry>
- <entry>Minute, (00-59), two digit</entry>
- <entry><constant>Zend_Date::MINUTE</constant></entry>
- <entry><emphasis>02</emphasis></entry>
- </row>
- <row>
- <entry>s</entry>
- <entry>Second, (0-59), one or two digit</entry>
- <entry><constant>Zend_Date::SECOND_SHORT</constant></entry>
- <entry><emphasis>2</emphasis></entry>
- </row>
- <row>
- <entry>ss</entry>
- <entry>Second, (00-59), two digit</entry>
- <entry><constant>Zend_Date::SECOND</constant></entry>
- <entry><emphasis>02</emphasis></entry>
- </row>
- <row>
- <entry>S</entry>
- <entry>Millisecond</entry>
- <entry><constant>Zend_Date::MILLISECOND</constant></entry>
- <entry><emphasis>20536</emphasis></entry>
- </row>
- <row>
- <entry>z</entry>
- <entry>Time zone, localized, abbreviated</entry>
- <entry><constant>Zend_Date::TIMEZONE</constant></entry>
- <entry><emphasis><constant>CET</constant></emphasis></entry>
- </row>
- <row>
- <entry>zz</entry>
- <entry>Time zone, localized, abbreviated</entry>
- <entry><constant>Zend_Date::TIMEZONE</constant></entry>
- <entry><emphasis><constant>CET</constant></emphasis></entry>
- </row>
- <row>
- <entry>zzz</entry>
- <entry>Time zone, localized, abbreviated</entry>
- <entry><constant>Zend_Date::TIMEZONE</constant></entry>
- <entry><emphasis><constant>CET</constant></emphasis></entry>
- </row>
- <row>
- <entry>zzzz</entry>
- <entry>Time zone, localized, complete</entry>
- <entry><constant>Zend_Date::TIMEZONE_NAME</constant></entry>
- <entry><emphasis><command>Europe/Paris</command></emphasis></entry>
- </row>
- <row>
- <entry>Z</entry>
- <entry>Difference of time zone</entry>
- <entry><constant>Zend_Date::GMT_DIFF</constant></entry>
- <entry><emphasis>+0100</emphasis></entry>
- </row>
- <row>
- <entry>ZZ</entry>
- <entry>Difference of time zone</entry>
- <entry><constant>Zend_Date::GMT_DIFF</constant></entry>
- <entry><emphasis>+0100</emphasis></entry>
- </row>
- <row>
- <entry><constant>ZZZ</constant></entry>
- <entry>Difference of time zone</entry>
- <entry><constant>Zend_Date::GMT_DIFF</constant></entry>
- <entry><emphasis>+0100</emphasis></entry>
- </row>
- <row>
- <entry><constant>ZZZZ</constant></entry>
- <entry>Difference of time zone, separated</entry>
- <entry><constant>Zend_Date::GMT_DIFF_SEP</constant></entry>
- <entry><emphasis>+01:00</emphasis></entry>
- </row>
- <row>
- <entry>A</entry>
- <entry>Milliseconds from the actual day</entry>
- <entry><constant>Zend_Date::MILLISECOND</constant></entry>
- <entry><emphasis>20563</emphasis></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <note>
- <para>
- Note that the default <acronym>ISO</acronym> format differs from
- <acronym>PHP</acronym>'s format which can be irritating if you have not used in
- previous. Especially the format specifiers for <emphasis>Year and Minute</emphasis>
- are often not used in the intended way.
- </para>
- <para>
- For <emphasis>year</emphasis> there are two specifiers available
- which are often mistaken. The <emphasis>Y</emphasis> specifier
- for the <acronym>ISO</acronym> year and the <emphasis>y</emphasis> specifier for the
- real year. The difference is small but significant.
- <emphasis>Y</emphasis> calculates the <acronym>ISO</acronym> year, which is often
- used for calendar formats. See for example the 31. December 2007. The real year is
- 2007, but it is the first day of the first week in the week 1 of the year 2008.
- So, if you are using '<command>dd.MM.yyyy</command>' you will get
- '<command>31.December.2007</command>' but if you use '<command>dd.MM.YYYY</command>'
- you will get '<command>31.December.2008</command>'. As you see this is no bug but a
- expected behaviour depending on the used specifiers.
- </para>
- <para>
- For <emphasis>minute</emphasis> the difference is not so big. <acronym>ISO</acronym>
- uses the specifier <emphasis>m</emphasis> for the minute, unlike
- <acronym>PHP</acronym> which uses <emphasis>i</emphasis>. So if you are getting no
- minute in your format check if you have used the right specifier.
- </para>
- </note>
- </sect2>
- <sect2 id="zend.date.constants.phpformats">
- <title>Self-Defined OUTPUT Formats Using PHP's date() Format Specifiers</title>
- <para>
- If you are more comfortable with <acronym>PHP</acronym>'s date format specifier than
- with <acronym>ISO</acronym> format specifiers, then you can use the
- <methodname>Zend_Date::setOptions(array('format_type' => 'php'))</methodname> method to
- switch <classname>Zend_Date</classname> methods from supporting <acronym>ISO</acronym>
- format specifiers to <acronym>PHP</acronym> <methodname>date()</methodname> type
- specifiers. Afterwards, all format parameters must be given with <ulink
- url="http://php.net/date">PHP's <methodname>date()</methodname> format
- specifiers</ulink>. The <acronym>PHP</acronym> date format lacks some of the formats
- supported by the <acronym>ISO</acronym> Format, and vice-versa. If you are not already
- comfortable with it, then use the standard <acronym>ISO</acronym> format instead. Also,
- if you have legacy code using <acronym>PHP</acronym>'s date format, then either manually
- convert it to the <acronym>ISO</acronym> format using <link
- linkend="zend.locale.date.normalize">Zend_Locale_Format::convertPhpToIsoFormat()</link>,
- or use <methodname>setOptions()</methodname>. The following examples illustrate the
- usage of constants from the table below to create self-defined formats.
- </para>
- <example id="zend.date.constants.phpformats.example-1">
- <title>Self-Defined Formats with PHP Specifier</title>
- <programlisting language="php"><![CDATA[
- $locale = new Zend_Locale('de_AT');
- Zend_Date::setOptions(array('format_type' => 'php'));
- $date = new Zend_Date(1234567890, false, $locale);
- // outputs something like 'February 16, 2007, 3:36 am'
- print $date->toString('F j, Y, g:i a');
- print $date->toString("'Format:D M j G:i:s T Y='D M j G:i:s T Y");
- ]]></programlisting>
- </example>
- <important>
- <title>PHP Date format and using constants</title>
- <para>
- It is important to note that <classname>Zend_Date</classname>'s constants are
- using the <acronym>ISO</acronym> notation. This means, that when you set
- <classname>Zend_Date</classname> to use the <acronym>PHP</acronym> notation,
- you should not use <classname>Zend_Date</classname>'s constants, but define the
- wished format manually. If you don't follow this recommendation, you can get
- unexpected results.
- </para>
- </important>
- <para>
- The following table shows the list of <acronym>PHP</acronym> date format specifiers with
- their equivalent <classname>Zend_Date</classname> constants and
- <acronym>CLDR</acronym> and <acronym>ISO</acronym> equivalent format specifiers. In most
- cases, when the <acronym>CLDR</acronym> and <acronym>ISO</acronym> format does not have
- an equivalent format specifier, the <acronym>PHP</acronym> format specifier is not
- altered by <methodname>Zend_Locale_Format::convertPhpToIsoFormat()</methodname>, and the
- <classname>Zend_Date</classname> methods then recognize these "peculiar"
- <acronym>PHP</acronym> format specifiers, even when in the default
- "<acronym>ISO</acronym>" format mode.
- </para>
- <table id="zend.date.constants.phpformats.table">
- <title>Constants for PHP Date Output</title>
- <tgroup cols="5">
- <thead>
- <row>
- <entry>Constant</entry>
- <entry>Description</entry>
- <entry>Corresponds best to</entry>
- <entry>closest <acronym>CLDR</acronym> equivalent</entry>
- <entry>Result</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>d</entry>
- <entry>Day of the month, two digit</entry>
- <entry><constant>Zend_Date::DAY</constant></entry>
- <entry>dd</entry>
- <entry><emphasis>09</emphasis></entry>
- </row>
- <row>
- <entry>D</entry>
- <entry>Day of the week, localized, abbreviated, three digit</entry>
- <entry><constant>Zend_Date::WEEKDAY_SHORT</constant></entry>
- <entry><constant>EEE</constant></entry>
- <entry><emphasis>Mon</emphasis></entry>
- </row>
- <row>
- <entry>j</entry>
- <entry>Day of the month, one or two digit</entry>
- <entry><constant>Zend_Date::DAY_SHORT</constant></entry>
- <entry>d</entry>
- <entry><emphasis>9</emphasis></entry>
- </row>
- <row>
- <entry>l (lowercase L)</entry>
- <entry>Day of the week, localized, complete</entry>
- <entry><constant>Zend_Date::WEEKDAY</constant></entry>
- <entry><constant>EEEE</constant></entry>
- <entry><emphasis>Monday</emphasis></entry>
- </row>
- <row>
- <entry>N</entry>
- <entry>Number of the weekday, one digit</entry>
- <entry><constant>Zend_Date::WEEKDAY_8601</constant></entry>
- <entry>e</entry>
- <entry><emphasis>4</emphasis></entry>
- </row>
- <row>
- <entry>S</entry>
- <entry>English suffixes for day of month, two chars</entry>
- <entry>no equivalent</entry>
- <entry>no equivalent</entry>
- <entry><emphasis>st</emphasis></entry>
- </row>
- <row>
- <entry>w</entry>
- <entry>Number of the weekday, 0=sunday, 6=saturday</entry>
- <entry><constant>Zend_Date::WEEKDAY_DIGIT</constant></entry>
- <entry>no equivalent</entry>
- <entry><emphasis>4</emphasis></entry>
- </row>
- <row>
- <entry>z</entry>
- <entry>Day of the year, one, two or three digit</entry>
- <entry><constant>Zend_Date::DAY_OF_YEAR</constant></entry>
- <entry>D</entry>
- <entry><emphasis>7</emphasis></entry>
- </row>
- <row>
- <entry>W</entry>
- <entry>Week, one or two digit</entry>
- <entry><constant>Zend_Date::WEEK</constant></entry>
- <entry>w</entry>
- <entry><emphasis>5</emphasis></entry>
- </row>
- <row>
- <entry>F</entry>
- <entry>Month, localized, complete</entry>
- <entry><constant>Zend_Date::MONTH_NAME</constant></entry>
- <entry><constant>MMMM</constant></entry>
- <entry><emphasis>February</emphasis></entry>
- </row>
- <row>
- <entry>m</entry>
- <entry>Month, two digit</entry>
- <entry><constant>Zend_Date::MONTH</constant></entry>
- <entry>MM</entry>
- <entry><emphasis>02</emphasis></entry>
- </row>
- <row>
- <entry>M</entry>
- <entry>Month, localized, abbreviated</entry>
- <entry><constant>Zend_Date::MONTH_NAME_SHORT</constant></entry>
- <entry><constant>MMM</constant></entry>
- <entry><emphasis>Feb</emphasis></entry>
- </row>
- <row>
- <entry>n</entry>
- <entry>Month, one or two digit</entry>
- <entry><constant>Zend_Date::MONTH_SHORT</constant></entry>
- <entry>M</entry>
- <entry><emphasis>2</emphasis></entry>
- </row>
- <row>
- <entry>t</entry>
- <entry>Number of days per month, one or two digits</entry>
- <entry><constant>Zend_Date::MONTH_DAYS</constant></entry>
- <entry>no equivalent</entry>
- <entry><emphasis>30</emphasis></entry>
- </row>
- <row>
- <entry>L</entry>
- <entry>Leapyear, boolean</entry>
- <entry><constant>Zend_Date::LEAPYEAR</constant></entry>
- <entry>no equivalent</entry>
- <entry><emphasis><constant>TRUE</constant></emphasis></entry>
- </row>
- <row>
- <entry>o</entry>
- <entry>
- Year according to <acronym>ISO</acronym> 8601, at least four digit
- </entry>
- <entry><constant>Zend_Date::YEAR_8601</constant></entry>
- <entry><constant>YYYY</constant></entry>
- <entry><emphasis>2009</emphasis></entry>
- </row>
- <row>
- <entry>Y</entry>
- <entry>Year, at least four digit</entry>
- <entry><constant>Zend_Date::YEAR</constant></entry>
- <entry>yyyy</entry>
- <entry><emphasis>2009</emphasis></entry>
- </row>
- <row>
- <entry>y</entry>
- <entry>Year, at least two digit</entry>
- <entry><constant>Zend_Date::YEAR_SHORT</constant></entry>
- <entry>yy</entry>
- <entry><emphasis>09</emphasis></entry>
- </row>
- <row>
- <entry>a</entry>
- <entry>Time of day, localized</entry>
- <entry><constant>Zend_Date::MERIDIEM</constant></entry>
- <entry>a (sort of, but likely to be uppercase)</entry>
- <entry><emphasis>vorm.</emphasis></entry>
- </row>
- <row>
- <entry>A</entry>
- <entry>Time of day, localized</entry>
- <entry><constant>Zend_Date::MERIDIEM</constant></entry>
- <entry>a (sort of, but no guarantee that the format is uppercase)</entry>
- <entry><emphasis><command>VORM.</command></emphasis></entry>
- </row>
- <row>
- <entry>B</entry>
- <entry>Swatch internet time</entry>
- <entry><constant>Zend_Date::SWATCH</constant></entry>
- <entry>no equivalent</entry>
- <entry><emphasis>1463</emphasis></entry>
- </row>
- <row>
- <entry>g</entry>
- <entry>Hour, (1-12), one or two digit</entry>
- <entry><constant>Zend_Date::HOUR_SHORT_AM</constant></entry>
- <entry>h</entry>
- <entry><emphasis>2</emphasis></entry>
- </row>
- <row>
- <entry>G</entry>
- <entry>Hour, (0-23), one or two digit</entry>
- <entry><constant>Zend_Date::HOUR_SHORT</constant></entry>
- <entry>H</entry>
- <entry><emphasis>2</emphasis></entry>
- </row>
- <row>
- <entry>h</entry>
- <entry>Hour, (01-12), two digit</entry>
- <entry><constant>Zend_Date::HOUR_AM</constant></entry>
- <entry>hh</entry>
- <entry><emphasis>02</emphasis></entry>
- </row>
- <row>
- <entry>H</entry>
- <entry>Hour, (00-23), two digit</entry>
- <entry><constant>Zend_Date::HOUR</constant></entry>
- <entry>HH</entry>
- <entry><emphasis>02</emphasis></entry>
- </row>
- <row>
- <entry>i</entry>
- <entry>Minute, (00-59), two digit</entry>
- <entry><constant>Zend_Date::MINUTE</constant></entry>
- <entry>mm</entry>
- <entry><emphasis>02</emphasis></entry>
- </row>
- <row>
- <entry>s</entry>
- <entry>Second, (00-59), two digit</entry>
- <entry><constant>Zend_Date::SECOND</constant></entry>
- <entry>ss</entry>
- <entry><emphasis>02</emphasis></entry>
- </row>
- <row>
- <entry>e</entry>
- <entry>Time zone, localized, complete</entry>
- <entry><constant>Zend_Date::TIMEZONE_NAME</constant></entry>
- <entry>zzzz</entry>
- <entry><emphasis><command>Europe/Paris</command></emphasis></entry>
- </row>
- <row>
- <entry>I</entry>
- <entry>Daylight</entry>
- <entry><constant>Zend_Date::DAYLIGHT</constant></entry>
- <entry>no equivalent</entry>
- <entry><emphasis>1</emphasis></entry>
- </row>
- <row>
- <entry>O</entry>
- <entry>Difference of time zone</entry>
- <entry><constant>Zend_Date::GMT_DIFF</constant></entry>
- <entry>Z or ZZ or <constant>ZZZ</constant></entry>
- <entry><emphasis>+0100</emphasis></entry>
- </row>
- <row>
- <entry>P</entry>
- <entry>Difference of time zone, separated</entry>
- <entry><constant>Zend_Date::GMT_DIFF_SEP</constant></entry>
- <entry><constant>ZZZZ</constant></entry>
- <entry><emphasis>+01:00</emphasis></entry>
- </row>
- <row>
- <entry>T</entry>
- <entry>Time zone, localized, abbreviated</entry>
- <entry><constant>Zend_Date::TIMEZONE</constant></entry>
- <entry>z or zz or zzz</entry>
- <entry><emphasis><constant>CET</constant></emphasis></entry>
- </row>
- <row>
- <entry>Z</entry>
- <entry>Time zone offset in seconds</entry>
- <entry><constant>Zend_Date::TIMEZONE_SECS</constant></entry>
- <entry>no equivalent</entry>
- <entry><emphasis>3600</emphasis></entry>
- </row>
- <row>
- <entry>c</entry>
- <entry>Standard Iso format output</entry>
- <entry><constant>Zend_Date::ISO_8601</constant></entry>
- <entry>no equivalent</entry>
- <entry><emphasis>2004-02-13T15:19:21+00:00</emphasis></entry>
- </row>
- <row>
- <entry>r</entry>
- <entry>Standard Rfc 2822 format output</entry>
- <entry><constant>Zend_Date::RFC_2822</constant></entry>
- <entry>no equivalent</entry>
- <entry><emphasis>Thu, 21 Dec 2000 16:01:07 +0200</emphasis></entry>
- </row>
- <row>
- <entry>U</entry>
- <entry>Unix timestamp</entry>
- <entry><constant>Zend_Date::TIMESTAMP</constant></entry>
- <entry>no equivalent</entry>
- <entry><emphasis>15275422364</emphasis></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </sect2>
- </sect1>
|