| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <!-- EN-Revision: 24249 -->
- <sect1 id="zend.date.constants">
- <title>日付関数全般用の定数</title>
- <para>
- <classname>Zend_Date</classname> のメソッドでパラメータ <varname>$parts</varname>
- を持つものはすべて、以下の定数のいずれかをパラメータとして指定できます。
- これにより、日付の中の特定の要素や使用する書式
- (例: <acronym>RFC</acronym> 822) を指定します。
- </para>
- <sect2 id="zend.date.constants.using">
- <title>定数の使用</title>
- <para>
- たとえば、定数<constant>Zend_Date::HOUR</constant> の使用法は次のようになります。
- 曜日・時・分・秒・その他の要素が世界各地でさまざまな形式で表されていたとしても、
- オブジェクトのタイムゾーン設定を使用して自動的に正しい値で計算を行います。
- これは、内部のタイムスタンプの値が何であるかや
- ユーザが世界中のどこにいるかとは関係がありません。
- 使用する単位にかかわらず、出力結果は <acronym>GMT</acronym> あるいは <acronym>UTC</acronym>
- あるいはロケールにあわせて地域化された形式となります。
- 以下の出力サンプルは、
- Europe/GMT+1 (ドイツ、オーストリア、フランスなど)
- にあわせて地域化された形式です。
- </para>
- <table id="zend.date.constants.using.table">
- <title>Zend_Date::HOUR を使用した操作</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>メソッド</entry>
- <entry>説明</entry>
- <entry>元の日付</entry>
- <entry>結果</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><methodname>get(Zend_Date::HOUR)</methodname></entry>
- <entry>時間を出力する</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>新しい時間を設定する</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>時間を足す</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>時間を引く</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>時間を比較し、0 か 1 あるいは -1 を返す</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry>1 (オブジェクト > 引数 の場合)</entry>
- </row>
- <row>
- <entry><methodname>copy(Zend_Date::HOUR)</methodname></entry>
- <entry>時間部のみをコピーする</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>時間を比較し、<constant>TRUE</constant> あるいは <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>時間を比較し、<constant>TRUE</constant> あるいは <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>時間を比較し、<constant>TRUE</constant> あるいは <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>全定数の一覧</title>
- <para>
- 日付/時刻の各要素に対応する定数が <classname>Zend_Date</classname> で定義されています。
- <classname>Zend_Date</classname> がサポートするすべての定数を以下に示します。
- </para>
- <table id="zend.date.constants.list.table-1">
- <title>日に関する定数</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>定数</entry>
- <entry>説明</entry>
- <entry>日付</entry>
- <entry>結果</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>Zend_Date::DAY</constant></entry>
- <entry>日 (二桁の数値)</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>日 (一桁あるいは二桁の数値)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry>
- <emphasis>6</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>Zend_Date::WEEKDAY</constant></entry>
- <entry>曜日 (地域化された完全な曜日名)</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>曜日 (地域化された曜日名の短縮形。2ないし4文字)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>Fri</emphasis> が金曜日を表す</entry>
- </row>
- <row>
- <entry><constant>Zend_Date::WEEKDAY_NAME</constant></entry>
- <entry>曜日 (地域化された曜日名の短縮形。1ないし2文字)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>Fr</emphasis> が金曜日を表す</entry>
- </row>
- <row>
- <entry><constant>Zend_Date::WEEKDAY_NARROW</constant></entry>
- <entry>曜日 (地域化された曜日名の短縮形。一文字)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>F</emphasis> が金曜日を表す</entry>
- </row>
- <row>
- <entry><constant>Zend_Date::WEEKDAY_DIGIT</constant></entry>
- <entry>曜日 (0 = 日曜日, 6 = 土曜日)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>5</emphasis> が金曜日を表す</entry>
- </row>
- <row>
- <entry><constant>Zend_Date::WEEKDAY_8601</constant></entry>
- <entry><acronym>ISO</acronym> 8601 にもとづく曜日 (1 = 月曜日, 7 = 日曜日)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>5</emphasis> が金曜日を表す</entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DAY_OF_YEAR</constant></entry>
- <entry>日数 (一桁あるいは二桁の数値)</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>英語で日付の後に追加する文字 (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>週に関する定数</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>定数</entry>
- <entry>説明</entry>
- <entry>日付</entry>
- <entry>結果</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>Zend_Date::WEEK</constant></entry>
- <entry>週 (1 から 53 までの数値)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>7</emphasis>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table id="zend.date.constants.list.table-3">
- <title>月に関する定数</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>定数</entry>
- <entry>説明</entry>
- <entry>日付</entry>
- <entry>結果</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>Zend_Date::MONTH_NAME</constant></entry>
- <entry>月 (地域化された完全な月名)</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>月 (地域化された月名の短縮形。2ないし4文字)</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>月 (地域化された月名の短縮形。1ないし2文字)</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>月 (二桁の月番号)</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>月 (一桁あるいは二桁の月番号)</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>当月の日数 (数値)</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>年に関する定数</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>定数</entry>
- <entry>説明</entry>
- <entry>日付</entry>
- <entry>結果</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>Zend_Date::YEAR</constant></entry>
- <entry>年 (数値)</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><acronym>ISO</acronym> 8601 の年 (数値)</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>年 (二桁の数値)</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><acronym>ISO</acronym> 8601 の年 (二桁の数値)</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>今年がうるう年かどうか? (<constant>TRUE</constant> あるいは <constant>FALSE</constant>)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis><constant>FALSE</constant></emphasis>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table id="zend.date.constants.list.table-5">
- <title>時間に関する定数</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>定数</entry>
- <entry>説明</entry>
- <entry>日付</entry>
- <entry>結果</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>Zend_Date::HOUR</constant></entry>
- <entry>時 (00-23、二桁)</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>時 (0-23、一桁あるいは二桁)</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>時 (1-12、一桁あるいは二桁)</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>時 (01-12、二桁)</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>分 (00-59、二桁)</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>分 (0-59、一桁あるいは二桁)</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>秒 (00-59、二桁)</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>秒 (0-59、一桁あるいは二桁)</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>ミリ秒 (理論上は無限大)</entry>
- <entry><command>2009-02-13T14:53:27.20546</command></entry>
- <entry><emphasis>20546</emphasis></entry>
- </row>
- <row>
- <entry><constant>Zend_Date::MERIDIEM</constant></entry>
- <entry>その日の中での時間 (午前/午後)</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>タイムゾーンに関する定数</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>定数</entry>
- <entry>説明</entry>
- <entry>日付</entry>
- <entry>結果</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>Zend_Date::TIMEZONE</constant></entry>
- <entry>タイムゾーン名 (省略形文字列)</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>タイムゾーン名 (文字列)</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><acronym>GMT</acronym> との時差を表す秒数 (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><acronym>GMT</acronym> との時差を表す秒数 (文字列)</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><acronym>GMT</acronym> との時差を表す秒数 (文字列、分割形式)</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>夏時間かそうでないか? (<constant>TRUE</constant> あるいは <constant>FALSE</constant>)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis><constant>FALSE</constant></emphasis>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table id="zend.date.constants.list.table-7">
- <title>日付フォーマットに関する定数 (タイムゾーンを含むフォーマット)</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>定数</entry>
- <entry>説明</entry>
- <entry>日付</entry>
- <entry>結果</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>Zend_Date::ISO_860</constant>1</entry>
- <entry><acronym>ISO</acronym> 8601 形式の日付 (文字列)</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><acronym>RFC</acronym> 2822 形式の日付 (文字列)</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> (1970 年 1 月 1 日からの経過秒数)</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><acronym>ATOM</acronym> 形式の日付 (文字列)</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>クッキー形式の日付 (クッキー用の文字列)</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><acronym>RFC</acronym> 822 形式の日付 (文字列)</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><acronym>RFC</acronym> 850 形式の日付 (文字列)</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><acronym>RFC</acronym> 1036 形式の日付 (文字列)</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><acronym>RFC</acronym> 1123 形式の日付 (文字列)</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><acronym>RSS</acronym> フィード形式の日付 (文字列)</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>
- <acronym>HTML</acronym> あるいは <acronym>HTTP</acronym> 用の
- <acronym>W3C</acronym> 形式の日付 (文字列)
- </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>
- 特に注意すべきなのは <constant>Zend_Date::DATES</constant> です。これは、
- <classname>Zend_Date</classname> で <emphasis>入力</emphasis>
- フォーマットを指定する際に使用すると、特別な働きをします。
- 入力フォーマットとして <varname>$part</varname> で使用すると、
- この定数は、さまざまな類似日付書式をできるだけ受け入れようとします。
- 経験則にもとづいて入力日付文字列を自動的に分解し、単純なエラーを (もしあれば)
- できるだけ修正します。たとえば年、月、日の順序がおかしい場合などです。
- </para>
- <table id="zend.date.constants.list.table-8">
- <title>日付および時刻フォーマットに関する定数 (ロケールによって変化する書式)</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>定数</entry>
- <entry>説明</entry>
- <entry>日付</entry>
- <entry>結果</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>Zend_Date::ERA</constant></entry>
- <entry>時代 (地域化された文字列の短縮形)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>AD</emphasis> (紀元後)</entry>
- </row>
- <row>
- <entry><constant>Zend_Date::ERA_NAME</constant></entry>
- <entry>時代 (地域化された文字列の完全系)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>anno domini</emphasis> (紀元後)</entry>
- </row>
- <row>
- <entry><emphasis>Zend_Date::DATES</emphasis>
- </entry>
- <entry>標準の日付 (地域化された文字列、デフォルト値)</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>完全な日付 (地域化された文字列、完全形)</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>長い日付 (地域化された文字列、長い形式)</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>通常の日付 (地域化された文字列、通常の形式)</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>省略形の日付 (地域化された文字列、短縮形式)</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>標準の時刻 (地域化された文字列、デフォルト値)</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>完全な時刻 (地域化された文字列、完全形)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>14:53 Uhr <acronym>CET</acronym></emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>Zend_Date::TIME_LONG</constant></entry>
- <entry>長い時刻 (地域化された文字列、長い形式)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>14:53:27 <acronym>CET</acronym></emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>Zend_Date::TIME_MEDIUM</constant></entry>
- <entry>通常の時刻 (地域化された文字列、通常の形式)</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>省略形の時刻 (地域化された文字列、短縮形式)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>14:53</emphasis>
- </entry>
- </row>
- <row>
- <entry><emphasis>Zend_Date::DATETIME</emphasis>
- </entry>
- <entry>標準の日付・時刻 (地域化された文字列、デフォルト値)</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>完全な日付・時刻 (地域化された文字列、完全な形式)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>Friday, 13. February 2009 14:53 Uhr <acronym>CET</acronym></emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DATETIME_LONG</constant></entry>
- <entry>長い日付・時刻 (地域化された文字列、長い形式)</entry>
- <entry>2009-02-13T14:53:27+01:00</entry>
- <entry><emphasis>13. February 2009 14:53:27 <acronym>CET</acronym></emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>Zend_Date::DATETIME_MEDIUM</constant></entry>
- <entry>通常の日付・時刻 (地域化された文字列、通常の形式)</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>省略形の日付・時刻 (地域化された文字列、短縮形式)</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>ISO 書式指定子を使用して自分で定義する出力フォーマット</title>
- <para>
- 上で示したもの意外の日付書式が必要な場合は、以下に示す
- <acronym>ISO</acronym> 書式トークンを使用して自分で書式を定義します。
- 以下の例は、下の表の定数を用いて独自の <acronym>ISO</acronym> 書式を作成する方法を示すものです。
- 書式の長さは無制限で、同じ定数を複数回使用してもかまいません。
- </para>
- <para>
- もし <acronym>PHP</acronym> 風の日付書式のほうがなじみがあるのなら、
- <acronym>ISO</acronym> 書式ではなく <acronym>PHP</acronym> の書式を用いるように変更することも可能です。
- しかし、<acronym>ISO</acronym> で定められているすべての書式が <acronym>PHP</acronym> の日付書式で指定できるわけではありません。
- <methodname>Zend_Date::setOptions(array('format_type' => 'php'))</methodname> メソッドを使用すると、
- <classname>Zend_Date</classname> のメソッドで <acronym>ISO</acronym> 書式指定子ではなく <acronym>PHP</acronym> の date() での指定子を用いるようになります
- (以下の <link linkend="zend.date.constants.phpformats">PHP の date() 関数の書式指定子を使用して
- 自分で定義する出力フォーマット</link> を参照ください)。
- </para>
- <example id="zend.date.constants.selfdefinedformats.example-1">
- <title>ISO 書式を使用した独自書式</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>ISO 8601 日付出力に関する定数</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>定数</entry>
- <entry>説明</entry>
- <entry>対応する要素</entry>
- <entry>結果</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>G</entry>
- <entry>時代 (地域化された省略形)</entry>
- <entry><constant>Zend_Date::ERA</constant></entry>
- <entry><emphasis>AD</emphasis>
- </entry>
- </row>
- <row>
- <entry>GG</entry>
- <entry>時代 (地域化された省略形)</entry>
- <entry><constant>Zend_Date::ERA</constant></entry>
- <entry><emphasis>AD</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>GGG</constant></entry>
- <entry>時代 (地域化された省略形)</entry>
- <entry><constant>Zend_Date::ERA</constant></entry>
- <entry><emphasis>AD</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>GGGG</constant></entry>
- <entry>時代 (地域化された完全形)</entry>
- <entry><constant>Zend_Date::ERA_NAME</constant></entry>
- <entry><emphasis>anno domini</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>GGGGG</constant></entry>
- <entry>時代 (地域化された省略形)</entry>
- <entry><constant>Zend_Date::ERA</constant></entry>
- <entry><emphasis>a</emphasis>
- </entry>
- </row>
- <row>
- <entry>y</entry>
- <entry>年 (最低一桁)</entry>
- <entry><constant>Zend_Date::YEAR</constant></entry>
- <entry><emphasis>9</emphasis>
- </entry>
- </row>
- <row>
- <entry>yy</entry>
- <entry>年 (最低二桁)</entry>
- <entry><constant>Zend_Date::YEAR_SHORT</constant></entry>
- <entry><emphasis>09</emphasis>
- </entry>
- </row>
- <row>
- <entry>yyy</entry>
- <entry>年 (最低三桁)</entry>
- <entry><constant>Zend_Date::YEAR</constant></entry>
- <entry><emphasis>2009</emphasis>
- </entry>
- </row>
- <row>
- <entry>yyyy</entry>
- <entry>年 (最低四桁)</entry>
- <entry><constant>Zend_Date::YEAR</constant></entry>
- <entry><emphasis>2009</emphasis>
- </entry>
- </row>
- <row>
- <entry>yyyyy</entry>
- <entry>年 (最低五桁)</entry>
- <entry><constant>Zend_Date::YEAR</constant></entry>
- <entry><emphasis>02009</emphasis>
- </entry>
- </row>
- <row>
- <entry>Y</entry>
- <entry><acronym>ISO</acronym> 8601 形式の年 (最低一桁)</entry>
- <entry><constant>Zend_Date::YEAR_8601</constant></entry>
- <entry><emphasis>9</emphasis>
- </entry>
- </row>
- <row>
- <entry>YY</entry>
- <entry><acronym>ISO</acronym> 8601 形式の年 (最低二桁)</entry>
- <entry><constant>Zend_Date::YEAR_SHORT_8601</constant></entry>
- <entry><emphasis>09</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>YYY</constant></entry>
- <entry><acronym>ISO</acronym> 8601 形式の年 (最低三桁)</entry>
- <entry><constant>Zend_Date::YEAR_8601</constant></entry>
- <entry><emphasis>2009</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>YYYY</constant></entry>
- <entry><acronym>ISO</acronym> 8601 形式の年 (最低四桁)</entry>
- <entry><constant>Zend_Date::YEAR_8601</constant></entry>
- <entry><emphasis>2009</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>YYYYY</constant></entry>
- <entry><acronym>ISO</acronym> 8601 形式の年 (最低五桁)</entry>
- <entry><constant>Zend_Date::YEAR_8601</constant></entry>
- <entry><emphasis>02009</emphasis>
- </entry>
- </row>
- <row>
- <entry>M</entry>
- <entry>月 (一桁あるいは二桁)</entry>
- <entry><constant>Zend_Date::MONTH_SHORT</constant></entry>
- <entry><emphasis>2</emphasis>
- </entry>
- </row>
- <row>
- <entry>MM</entry>
- <entry>月 (二桁)</entry>
- <entry><constant>Zend_Date::MONTH</constant></entry>
- <entry><emphasis>02</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>MMM</constant></entry>
- <entry>月 (地域化された省略形)</entry>
- <entry><constant>Zend_Date::MONTH_NAME_SHORT</constant></entry>
- <entry><emphasis>Feb</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>MMMM</constant></entry>
- <entry>月 (地域化された完全形)</entry>
- <entry><constant>Zend_Date::MONTH_NAME</constant></entry>
- <entry><emphasis>February</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>MMMMM</constant></entry>
- <entry>月 (地域化された省略形、一桁)</entry>
- <entry><constant>Zend_Date::MONTH_NAME_NARROW</constant></entry>
- <entry><emphasis>F</emphasis>
- </entry>
- </row>
- <row>
- <entry>w</entry>
- <entry>週 (一桁あるいは二桁)</entry>
- <entry><constant>Zend_Date::WEEK</constant></entry>
- <entry><emphasis>5</emphasis>
- </entry>
- </row>
- <row>
- <entry>ww</entry>
- <entry>週 (二桁)</entry>
- <entry><constant>Zend_Date::WEEK</constant></entry>
- <entry><emphasis>05</emphasis>
- </entry>
- </row>
- <row>
- <entry>d</entry>
- <entry>その月の日付 (一桁あるいは二桁)</entry>
- <entry><constant>Zend_Date::DAY_SHORT</constant></entry>
- <entry><emphasis>9</emphasis>
- </entry>
- </row>
- <row>
- <entry>dd</entry>
- <entry>その月の日付 (二桁)</entry>
- <entry><constant>Zend_Date::DAY</constant></entry>
- <entry><emphasis>09</emphasis>
- </entry>
- </row>
- <row>
- <entry>D</entry>
- <entry>その年の日付 (一桁、二桁あるいは三桁)</entry>
- <entry><constant>Zend_Date::DAY_OF_YEAR</constant></entry>
- <entry><emphasis>7</emphasis>
- </entry>
- </row>
- <row>
- <entry>DD</entry>
- <entry>その年の日付 (二桁あるいは三桁)</entry>
- <entry><constant>Zend_Date::DAY_OF_YEAR</constant></entry>
- <entry><emphasis>07</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>DDD</constant></entry>
- <entry>その年の日付 (三桁)</entry>
- <entry><constant>Zend_Date::DAY_OF_YEAR</constant></entry>
- <entry><emphasis>007</emphasis>
- </entry>
- </row>
- <row>
- <entry>E</entry>
- <entry>曜日 (地域化された省略形、一文字)</entry>
- <entry><constant>Zend_Date::WEEKDAY_NARROW</constant></entry>
- <entry><emphasis>M</emphasis>
- </entry>
- </row>
- <row>
- <entry>EE</entry>
- <entry>曜日 (地域化された省略形、二文字以上)</entry>
- <entry><constant>Zend_Date::WEEKDAY_NAME</constant></entry>
- <entry><emphasis>Mo</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>EEE</constant></entry>
- <entry>曜日 (地域化された省略形、三文字)</entry>
- <entry><constant>Zend_Date::WEEKDAY_SHORT</constant></entry>
- <entry><emphasis>Mon</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>EEEE</constant></entry>
- <entry>曜日 (地域化された完全形)</entry>
- <entry><constant>Zend_Date::WEEKDAY</constant></entry>
- <entry><emphasis>Monday</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>EEEEE</constant></entry>
- <entry>曜日 (地域化された省略形、一桁)</entry>
- <entry><constant>Zend_Date::WEEKDAY_NARROW</constant></entry>
- <entry><emphasis>M</emphasis>
- </entry>
- </row>
- <row>
- <entry>e</entry>
- <entry>曜日番号 (一桁)</entry>
- <entry><constant>Zend_Date::WEEKDAY_DIGIT</constant></entry>
- <entry><emphasis>4</emphasis>
- </entry>
- </row>
- <row>
- <entry>ee</entry>
- <entry>曜日番号 (二桁)</entry>
- <entry><constant>Zend_Date::WEEKDAY_NARROW</constant></entry>
- <entry><emphasis>04</emphasis>
- </entry>
- </row>
- <row>
- <entry>a</entry>
- <entry>午前/午後 (地域化された形式)</entry>
- <entry><constant>Zend_Date::MERIDIEM</constant></entry>
- <entry><emphasis>vorm.</emphasis>
- </entry>
- </row>
- <row>
- <entry>h</entry>
- <entry>時間 (1-12) (一桁あるいは二桁)</entry>
- <entry><constant>Zend_Date::HOUR_SHORT_AM</constant></entry>
- <entry><emphasis>2</emphasis>
- </entry>
- </row>
- <row>
- <entry>hh</entry>
- <entry>時間 (01-12) (二桁)</entry>
- <entry><constant>Zend_Date::HOUR_AM</constant></entry>
- <entry><emphasis>02</emphasis>
- </entry>
- </row>
- <row>
- <entry>H</entry>
- <entry>時間 (0-23) (一桁あるいは二桁)</entry>
- <entry><constant>Zend_Date::HOUR_SHORT</constant></entry>
- <entry><emphasis>2</emphasis>
- </entry>
- </row>
- <row>
- <entry>HH</entry>
- <entry>時間 (00-23) (二桁)</entry>
- <entry><constant>Zend_Date::HOUR</constant></entry>
- <entry><emphasis>02</emphasis>
- </entry>
- </row>
- <row>
- <entry>m</entry>
- <entry>分 (0-59) (一桁あるいは二桁)</entry>
- <entry><constant>Zend_Date::MINUTE_SHORT</constant></entry>
- <entry><emphasis>2</emphasis>
- </entry>
- </row>
- <row>
- <entry>mm</entry>
- <entry>分 (00-59) (二桁)</entry>
- <entry><constant>Zend_Date::MINUTE</constant></entry>
- <entry><emphasis>02</emphasis>
- </entry>
- </row>
- <row>
- <entry>s</entry>
- <entry>秒 (0-59) (一桁あるいは二桁)</entry>
- <entry><constant>Zend_Date::SECOND_SHORT</constant></entry>
- <entry><emphasis>2</emphasis>
- </entry>
- </row>
- <row>
- <entry>ss</entry>
- <entry>秒 (00-59) (二桁)</entry>
- <entry><constant>Zend_Date::SECOND</constant></entry>
- <entry><emphasis>02</emphasis>
- </entry>
- </row>
- <row>
- <entry>S</entry>
- <entry>ミリ秒</entry>
- <entry><constant>Zend_Date::MILLISECOND</constant></entry>
- <entry><emphasis>20536</emphasis>
- </entry>
- </row>
- <row>
- <entry>z</entry>
- <entry>タイムゾーン (地域化された省略形)</entry>
- <entry><constant>Zend_Date::TIMEZONE</constant></entry>
- <entry><emphasis>CET</emphasis>
- </entry>
- </row>
- <row>
- <entry>zz</entry>
- <entry>タイムゾーン (地域化された省略形)</entry>
- <entry><constant>Zend_Date::TIMEZONE</constant></entry>
- <entry><emphasis>CET</emphasis>
- </entry>
- </row>
- <row>
- <entry>zzz</entry>
- <entry>タイムゾーン (地域化された省略形)</entry>
- <entry><constant>Zend_Date::TIMEZONE</constant></entry>
- <entry><emphasis>CET</emphasis>
- </entry>
- </row>
- <row>
- <entry>zzzz</entry>
- <entry>タイムゾーン (地域化された完全形)</entry>
- <entry><constant>Zend_Date::TIMEZONE_NAME</constant></entry>
- <entry><emphasis>Europe/Paris</emphasis>
- </entry>
- </row>
- <row>
- <entry>Z</entry>
- <entry>タイムゾーンの時差</entry>
- <entry><constant>Zend_Date::GMT_DIFF</constant></entry>
- <entry><emphasis>+0100</emphasis>
- </entry>
- </row>
- <row>
- <entry>ZZ</entry>
- <entry>タイムゾーンの時差</entry>
- <entry><constant>Zend_Date::GMT_DIFF</constant></entry>
- <entry><emphasis>+0100</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>ZZZ</constant></entry>
- <entry>タイムゾーンの時差</entry>
- <entry><constant>Zend_Date::GMT_DIFF</constant></entry>
- <entry><emphasis>+0100</emphasis>
- </entry>
- </row>
- <row>
- <entry><constant>ZZZZ</constant></entry>
- <entry>タイムゾーンの時差 (分割形式)</entry>
- <entry><constant>Zend_Date::GMT_DIFF_SEP</constant></entry>
- <entry><emphasis>+01:00</emphasis>
- </entry>
- </row>
- <row>
- <entry>A</entry>
- <entry>実績日付からのミリ秒</entry>
- <entry><constant>Zend_Date::MILLISECOND</constant></entry>
- <entry><emphasis>20563</emphasis>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <note>
- <para>
- デフォルトの <acronym>ISO</acronym> フォーマットは、<acronym>PHP</acronym> のフォーマットとは異なることに注意しましょう。
- これまでに使ったことがない方は、少々いらいらするかもしれません。
- 特に、<emphasis>「年」と「分」</emphasis>
- に関する指定子については、なかなか期待通りに動作しないことでしょう。
- </para>
- <para>
- <emphasis>「年」</emphasis>
- については、間違えやすい指定子がふたつあります。
- <acronym>ISO</acronym> 形式の年を表す <emphasis>Y</emphasis> 指定子と、
- 実際の年を表す <emphasis>y</emphasis> 指定子です。
- 両者の違いは些細なものではありますが、非常に重要です。
- <emphasis>Y</emphasis> は <acronym>ISO</acronym> 形式の年を算出するものです。
- これは、カレンダーを作成する際によく用いられます。
- 2007 年 12 月 31 日を例にとって考えてみましょう。
- 実際の年は 2007 ですが、この日は
- 2008 年の最初の週 (第 1 週) の最初の日でもあります。
- したがって、'dd.MM.yyyy' として場合は '31.December.2007'
- が得られますが、'dd.MM.YYYY' とした場合の結果は '31.December.2008'
- となるのです。これはバグではなく、期待通りの振る舞いです。
- これが、ふたつの指定子の違いとなります。
- </para>
- <para>
- <emphasis>「分」</emphasis>
- の場合は、違いはそれほど大きくはありません。<acronym>ISO</acronym> では「分」
- を表す指定子として <emphasis>m</emphasis>
- を使用します。<acronym>PHP</acronym> が使っている <emphasis>i</emphasis>
- ではありません。分を取得する書式指定をする際には、
- 正しい指定子を使っているかどうかを確認するようにしましょう。
- </para>
- </note>
- </sect2>
- <sect2 id="zend.date.constants.phpformats">
- <title>PHP の date() 関数の書式指定子を使用して自分で定義する出力フォーマット</title>
- <para>
- もし <acronym>PHP</acronym> の日付書式指定子のほうが <acronym>ISO</acronym> 書式指定子よりなじみがあるのなら、
- <methodname>Zend_Date::setOptions(array('format_type' => 'php'))</methodname> を使用しましょう。これで、
- <classname>Zend_Date</classname> のメソッドで <acronym>ISO</acronym> 書式指定子ではなく <acronym>PHP</acronym> の date() での指定子を用いるようになります
- その後の書式パラメータは、すべて
- <ulink url="http://php.net/date"><acronym>PHP</acronym> の <methodname>date()</methodname> 書式指定子</ulink>
- に従うようになります。<acronym>PHP</acronym> の日付書式には含まれていないけれども <acronym>ISO</acronym> の書式には含まれるもの、
- またその逆もあります。もしそれほど <acronym>PHP</acronym> の日付書式になじみがないのなら、標準の
- <acronym>ISO</acronym> 書式を使用しましょう。既存のコードで <acronym>PHP</acronym> の日付書式をしているものがある場合は
- <link linkend="zend.locale.date.normalize">Zend_Locale_Format::convertPhpToIsoFormat()</link>
- で <acronym>ISO</acronym> 書式に変換するか、<methodname>setOptions()</methodname>
- を使用します。次の例は、下の表の定数を用いて独自の書式を定義するものです。
- </para>
- <example id="zend.date.constants.phpformats.example-1">
- <title>PHP の指定子を使用した独自書式</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);
- // 出力は '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 の日付書式と定数の使用について</title>
- <para>
- <classname>Zend_Date</classname> の定数は
- <acronym>ISO</acronym> 記法を使っているということに注意しましょう。
- つまり、<classname>Zend_Date</classname> で <acronym>PHP</acronym>
- 記法を使うように設定している場合は、<classname>Zend_Date</classname>
- の定数は使えません。自分で書式を定義する必要があります。
- この忠告に従わなければ、予期せぬ結果を得ることになるでしょう。
- </para>
- </important>
- <para>
- 次の表は、<acronym>PHP</acronym> の日付書式指定子とそれに対応する <classname>Zend_Date</classname> の定数、
- そして同等な <acronym>CLDR</acronym>/ISO 書式指定子を示したものです。
- たいていの場合は、もし <acronym>CLDR</acronym>/ISO 書式に同等のものがなければ
- <methodname>Zend_Locale_Format::convertPhpToIsoFormat()</methodname>
- で <acronym>PHP</acronym> の書式指定子がそのまま残されます。そして <classname>Zend_Date</classname>
- のメソッドは、たとえ "ISO" 書式モードであったとしても、これらの
- <acronym>PHP</acronym> "独特の" 書式指定を理解します。
- </para>
- <table id="zend.date.constants.phpformats.table">
- <title>PHP の日付出力用の定数</title>
- <tgroup cols="5">
- <thead>
- <row>
- <entry>定数</entry>
- <entry>説明</entry>
- <entry>対応する要素</entry>
- <entry><acronym>CLDR</acronym> での同等の指定子</entry>
- <entry>結果</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>d</entry>
- <entry>その月の日付 (二桁)</entry>
- <entry><constant>Zend_Date::DAY</constant></entry>
- <entry>dd</entry>
- <entry><emphasis>09</emphasis>
- </entry>
- </row>
- <row>
- <entry>D</entry>
- <entry>曜日 (地域化された省略形、三文字)</entry>
- <entry><constant>Zend_Date::WEEKDAY_SHORT</constant></entry>
- <entry>EEE</entry>
- <entry><emphasis>Mon</emphasis>
- </entry>
- </row>
- <row>
- <entry>j</entry>
- <entry>その月の日付 (一桁あるいは二桁)</entry>
- <entry><constant>Zend_Date::DAY_SHORT</constant></entry>
- <entry>d</entry>
- <entry><emphasis>9</emphasis>
- </entry>
- </row>
- <row>
- <entry>l (小文字の L)</entry>
- <entry>曜日 (地域化された完全形)</entry>
- <entry><constant>Zend_Date::WEEKDAY</constant></entry>
- <entry>EEEE</entry>
- <entry><emphasis>Monday</emphasis>
- </entry>
- </row>
- <row>
- <entry>N</entry>
- <entry>曜日番号 (一桁)</entry>
- <entry><constant>Zend_Date::WEEKDAY_8601</constant></entry>
- <entry>e</entry>
- <entry><emphasis>4</emphasis>
- </entry>
- </row>
- <row>
- <entry>S</entry>
- <entry>英語の日付の後につける接尾辞 (二文字)</entry>
- <entry>なし</entry>
- <entry>なし</entry>
- <entry><emphasis>st</emphasis>
- </entry>
- </row>
- <row>
- <entry>w</entry>
- <entry>曜日番号 (0=日曜日、6=土曜日)</entry>
- <entry><constant>Zend_Date::WEEKDAY_DIGIT</constant></entry>
- <entry>なし</entry>
- <entry><emphasis>4</emphasis>
- </entry>
- </row>
- <row>
- <entry>z</entry>
- <entry>その年の日付 (一桁、二桁あるいは三桁)</entry>
- <entry><constant>Zend_Date::DAY_OF_YEAR</constant></entry>
- <entry>D</entry>
- <entry><emphasis>7</emphasis>
- </entry>
- </row>
- <row>
- <entry>W</entry>
- <entry>週 (一桁あるいは二桁)</entry>
- <entry><constant>Zend_Date::WEEK</constant></entry>
- <entry>w</entry>
- <entry><emphasis>5</emphasis>
- </entry>
- </row>
- <row>
- <entry>F</entry>
- <entry>月 (地域化された完全形)</entry>
- <entry><constant>Zend_Date::MONTH_NAME</constant></entry>
- <entry>MMMM</entry>
- <entry><emphasis>February</emphasis>
- </entry>
- </row>
- <row>
- <entry>m</entry>
- <entry>月 (二桁)</entry>
- <entry><constant>Zend_Date::MONTH</constant></entry>
- <entry>MM</entry>
- <entry><emphasis>02</emphasis>
- </entry>
- </row>
- <row>
- <entry>M</entry>
- <entry>月 (地域化された省略形)</entry>
- <entry><constant>Zend_Date::MONTH_NAME_SHORT</constant></entry>
- <entry>MMM</entry>
- <entry><emphasis>Feb</emphasis>
- </entry>
- </row>
- <row>
- <entry>n</entry>
- <entry>月 (一桁あるいは二桁)</entry>
- <entry><constant>Zend_Date::MONTH_SHORT</constant></entry>
- <entry>M</entry>
- <entry><emphasis>2</emphasis>
- </entry>
- </row>
- <row>
- <entry>t</entry>
- <entry>その月の日数 (一桁あるいは二桁)</entry>
- <entry><constant>Zend_Date::MONTH_DAYS</constant></entry>
- <entry>なし</entry>
- <entry><emphasis>30</emphasis>
- </entry>
- </row>
- <row>
- <entry>L</entry>
- <entry>うるう年かどうか</entry>
- <entry><constant>Zend_Date::LEAPYEAR</constant></entry>
- <entry>なし</entry>
- <entry><emphasis><constant>TRUE</constant></emphasis>
- </entry>
- </row>
- <row>
- <entry>o</entry>
- <entry><acronym>ISO</acronym> 8601 形式の年 (最低四桁)</entry>
- <entry><constant>Zend_Date::YEAR_8601</constant></entry>
- <entry>YYYY</entry>
- <entry><emphasis>2009</emphasis>
- </entry>
- </row>
- <row>
- <entry>Y</entry>
- <entry>年 (最低四桁)</entry>
- <entry><constant>Zend_Date::YEAR</constant></entry>
- <entry>yyyy</entry>
- <entry><emphasis>2009</emphasis>
- </entry>
- </row>
- <row>
- <entry>y</entry>
- <entry>年 (最低二桁)</entry>
- <entry><constant>Zend_Date::YEAR_SHORT</constant></entry>
- <entry>yy</entry>
- <entry><emphasis>09</emphasis>
- </entry>
- </row>
- <row>
- <entry>a</entry>
- <entry>午前/午後 (地域化された形式)</entry>
- <entry><constant>Zend_Date::MERIDIEM</constant></entry>
- <!-- TODO : to be translated -->
- <entry>a (sort of, but likely to be uppercase)</entry>
- <entry><emphasis>vorm.</emphasis>
- </entry>
- </row>
- <row>
- <entry>A</entry>
- <entry>午前/午後 (地域化された形式)</entry>
- <entry><constant>Zend_Date::MERIDIEM</constant></entry>
- <!-- TODO : to be translated -->
- <entry>a (sort of, but no guarantee that the format is uppercase)</entry>
- <entry><emphasis>VORM.</emphasis>
- </entry>
- </row>
- <row>
- <entry>B</entry>
- <entry>Swatch インターネット時間</entry>
- <entry><constant>Zend_Date::SWATCH</constant></entry>
- <entry>なし</entry>
- <entry><emphasis>1463</emphasis>
- </entry>
- </row>
- <row>
- <entry>g</entry>
- <entry>時間 (1-12) (一桁あるいは二桁)</entry>
- <entry><constant>Zend_Date::HOUR_SHORT_AM</constant></entry>
- <entry>h</entry>
- <entry><emphasis>2</emphasis>
- </entry>
- </row>
- <row>
- <entry>G</entry>
- <entry>時間 (0-23) (一桁あるいは二桁)</entry>
- <entry><constant>Zend_Date::HOUR_SHORT</constant></entry>
- <entry>H</entry>
- <entry><emphasis>2</emphasis>
- </entry>
- </row>
- <row>
- <entry>h</entry>
- <entry>時間 (01-12) (二桁)</entry>
- <entry><constant>Zend_Date::HOUR_AM</constant></entry>
- <entry>hh</entry>
- <entry><emphasis>02</emphasis>
- </entry>
- </row>
- <row>
- <entry>H</entry>
- <entry>時間 (00-23) (二桁)</entry>
- <entry><constant>Zend_Date::HOUR</constant></entry>
- <entry>HH</entry>
- <entry><emphasis>02</emphasis>
- </entry>
- </row>
- <row>
- <entry>i</entry>
- <entry>分 (00-59) (二桁)</entry>
- <entry><constant>Zend_Date::MINUTE</constant></entry>
- <entry>mm</entry>
- <entry><emphasis>02</emphasis>
- </entry>
- </row>
- <row>
- <entry>s</entry>
- <entry>秒 (00-59) (二桁)</entry>
- <entry><constant>Zend_Date::SECOND</constant></entry>
- <entry>ss</entry>
- <entry><emphasis>02</emphasis>
- </entry>
- </row>
- <row>
- <entry>e</entry>
- <entry>タイムゾーン (地域化された完全形)</entry>
- <entry><constant>Zend_Date::TIMEZONE_NAME</constant></entry>
- <entry>zzzz</entry>
- <entry><emphasis>Europe/Paris</emphasis>
- </entry>
- </row>
- <row>
- <entry>I</entry>
- <entry>夏時間</entry>
- <entry><constant>Zend_Date::DAYLIGHT</constant></entry>
- <entry>なし</entry>
- <entry><emphasis>1</emphasis>
- </entry>
- </row>
- <row>
- <entry>O</entry>
- <entry>タイムゾーンの時差</entry>
- <entry><constant>Zend_Date::GMT_DIFF</constant></entry>
- <entry>Z、ZZ あるいは <constant>ZZZ</constant></entry>
- <entry><emphasis>+0100</emphasis>
- </entry>
- </row>
- <row>
- <entry>P</entry>
- <entry>タイムゾーンの時差 (分割形式)</entry>
- <entry><constant>Zend_Date::GMT_DIFF_SEP</constant></entry>
- <entry>ZZZZ</entry>
- <entry><emphasis>+01:00</emphasis>
- </entry>
- </row>
- <row>
- <entry>T</entry>
- <entry>タイムゾーン (地域化された省略形)</entry>
- <entry><constant>Zend_Date::TIMEZONE</constant></entry>
- <entry>z、zz あるいは zzz</entry>
- <entry><emphasis>CET</emphasis>
- </entry>
- </row>
- <row>
- <entry>Z</entry>
- <entry>タイムゾーンの時差秒数</entry>
- <entry><constant>Zend_Date::TIMEZONE_SECS</constant></entry>
- <entry>なし</entry>
- <entry><emphasis>3600</emphasis>
- </entry>
- </row>
- <row>
- <entry>c</entry>
- <entry>標準の Iso 書式の出力</entry>
- <entry><constant>Zend_Date::ISO_8601</constant></entry>
- <entry>なし</entry>
- <entry><emphasis>2004-02-12T15:19:21+00:00</emphasis>
- </entry>
- </row>
- <row>
- <entry>r</entry>
- <entry>標準の Rfc 2822 書式の出力</entry>
- <entry><constant>Zend_Date::RFC_2822</constant></entry>
- <entry>なし</entry>
- <entry><emphasis>Thu, 21 Dec 2000 16:01:07 +0200</emphasis>
- </entry>
- </row>
- <row>
- <entry>U</entry>
- <entry>Unix タイムスタンプ</entry>
- <entry><constant>Zend_Date::TIMESTAMP</constant></entry>
- <entry>なし</entry>
- <entry><emphasis>15275422364</emphasis>
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </sect2>
- </sect1>
|