<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>The IntlDateFormatter class</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="intltimezone.usedaylighttime.html">IntlTimeZone::useDaylightTime</a></div> <div class="next" style="text-align: right; float: right;"><a href="intldateformatter.create.html">IntlDateFormatter::create</a></div> <div class="up"><a href="book.intl.html">intl</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="class.intldateformatter" class="reference"> <h1 class="title">The IntlDateFormatter class</h1> <div class="partintro"><p class="verinfo">(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)</p> <div class="section" id="intldateformatter.intro"> <h2 class="title">Introduction</h2> <p class="simpara"> Date Formatter is a concrete class that enables locale-dependent formatting/parsing of dates using pattern strings and/or canned patterns. </p> <p class="simpara"> This class represents the ICU date formatting functionality. It allows users to display dates in a localized format or to parse strings into PHP date values using pattern strings and/or canned patterns. </p> </div> <div class="section" id="intldateformatter.synopsis"> <h2 class="title">Class synopsis</h2> <div class="classsynopsis"> <div class="ooclass"> </div> <div class="classsynopsisinfo"> <span class="ooclass"> <strong class="classname">IntlDateFormatter</strong> </span> {</div> <div class="classsynopsisinfo classsynopsisinfo_comment">/* Methods */</div> <div class="constructorsynopsis dc-description"> <span class="modifier">public</span> <span class="methodname"><a href="intldateformatter.create.html" class="methodname">__construct</a></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$locale</code></span> , <span class="methodparam"><span class="type">int</span> <code class="parameter">$datetype</code></span> , <span class="methodparam"><span class="type">int</span> <code class="parameter">$timetype</code></span> [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$timezone</code><span class="initializer"> = NULL</span></span> [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$calendar</code><span class="initializer"> = NULL</span></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$pattern</code><span class="initializer"> = ''</span></span> ]]] )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="modifier">static</span> <span class="type">IntlDateFormatter</span> <span class="methodname"><a href="intldateformatter.create.html" class="methodname">create</a></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$locale</code></span> , <span class="methodparam"><span class="type">int</span> <code class="parameter">$datetype</code></span> , <span class="methodparam"><span class="type">int</span> <code class="parameter">$timetype</code></span> [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$timezone</code><span class="initializer"> = NULL</span></span> [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$calendar</code><span class="initializer"> = NULL</span></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$pattern</code><span class="initializer"> = ''</span></span> ]]] )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">string</span> <span class="methodname"><a href="intldateformatter.format.html" class="methodname">format</a></span> ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="modifier">static</span> <span class="type">string</span> <span class="methodname"><a href="intldateformatter.formatobject.html" class="methodname">formatObject</a></span> ( <span class="methodparam"><span class="type">object</span> <code class="parameter">$object</code></span> [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$format</code><span class="initializer"> = NULL</span></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$locale</code><span class="initializer"> = NULL</span></span> ]] )</div> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><a href="intldateformatter.getcalendar.html" class="methodname">getCalendar</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">int</span> <span class="methodname"><a href="intldateformatter.getdatetype.html" class="methodname">getDateType</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">int</span> <span class="methodname"><a href="intldateformatter.geterrorcode.html" class="methodname">getErrorCode</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">string</span> <span class="methodname"><a href="intldateformatter.geterrormessage.html" class="methodname">getErrorMessage</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">string</span> <span class="methodname"><a href="intldateformatter.getlocale.html" class="methodname">getLocale</a></span> ([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$which</code></span> ] )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">string</span> <span class="methodname"><a href="intldateformatter.getpattern.html" class="methodname">getPattern</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">int</span> <span class="methodname"><a href="intldateformatter.gettimetype.html" class="methodname">getTimeType</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">string</span> <span class="methodname"><a href="intldateformatter.gettimezoneid.html" class="methodname">getTimeZoneId</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">IntlCalendar</span> <span class="methodname"><a href="intldateformatter.getcalendarobject.html" class="methodname">getCalendarObject</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">IntlTimeZone</span> <span class="methodname"><a href="intldateformatter.gettimezone.html" class="methodname">getTimeZone</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><a href="intldateformatter.islenient.html" class="methodname">isLenient</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><a href="intldateformatter.localtime.html" class="methodname">localtime</a></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$value</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$position</code></span> ] )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">int</span> <span class="methodname"><a href="intldateformatter.parse.html" class="methodname">parse</a></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$value</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$position</code></span> ] )</div> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><a href="intldateformatter.setcalendar.html" class="methodname">setCalendar</a></span> ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$which</code></span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><a href="intldateformatter.setlenient.html" class="methodname">setLenient</a></span> ( <span class="methodparam"><span class="type">bool</span> <code class="parameter">$lenient</code></span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><a href="intldateformatter.setpattern.html" class="methodname">setPattern</a></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$pattern</code></span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><a href="intldateformatter.settimezoneid.html" class="methodname">setTimeZoneId</a></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$zone</code></span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">boolean</span> <span class="methodname"><a href="intldateformatter.settimezone.html" class="methodname">setTimeZone</a></span> ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$zone</code></span> )</div> }</div> </div> <div class="section" id="intldateformatter.seealso"> <h2 class="title">See Also</h2> <p class="para"> <ul class="simplelist"> <li class="member"> <a href="http://www.icu-project.org/apiref/icu4c/udat_8h.html#details" class="link external">» ICU Date formatter</a> </li> </ul> <ul class="simplelist"> <li class="member"> <a href="http://www.icu-project.org/apiref/icu4c/classSimpleDateFormat.html#details" class="link external">» ICU Date formats</a> </li> </ul> </p> </div> <div class="section" id="intl.intldateformatter-constants"> <h2 class="title">Predefined Constants</h2> <p class="para"> These constants are used to specify different formats in the constructor for DateType and TimeType. <dl> <dt id="intldateformatter.constants.none"> <span class="term"> <strong><code>IntlDateFormatter::NONE</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara">Do not include this element</span> </dd> </dt> <dt id="intldateformatter.constants.full"> <span class="term"> <strong><code>IntlDateFormatter::FULL</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara">Completely specified style (Tuesday, April 12, 1952 AD or 3:30:42pm PST)</span> </dd> </dt> <dt id="intldateformatter.constants.long"> <span class="term"> <strong><code>IntlDateFormatter::LONG</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara">Long style (January 12, 1952 or 3:30:32pm)</span> </dd> </dt> <dt id="intldateformatter.constants.medium"> <span class="term"> <strong><code>IntlDateFormatter::MEDIUM</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara">Medium style (Jan 12, 1952)</span> </dd> </dt> <dt id="intldateformatter.constants.short"> <span class="term"> <strong><code>IntlDateFormatter::SHORT</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara">Most abbreviated style, only essential data (12/13/52 or 3:30pm)</span> </dd> </dt> </dl> </p> <p class="para" id="intl.intldateformatter-constants.calendartypes"> The following int constants are used to specify the calendar. These calendars are all based directly on the Gregorian calendar. Non-Gregorian calendars need to be specified in locale. Examples might include locale="hi@calendar=BUDDHIST". <dl> <dt id="intldateformatter.constants.traditional"> <span class="term"> <strong><code>IntlDateFormatter::TRADITIONAL</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara">Non-Gregorian Calendar</span> </dd> </dt> <dt id="intldateformatter.constants.gregorian"> <span class="term"> <strong><code>IntlDateFormatter::GREGORIAN</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara">Gregorian Calendar</span> </dd> </dt> </dl> </p> </div> </div> <h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="intldateformatter.create.html">IntlDateFormatter::create</a> — Create a date formatter</li><li><a href="intldateformatter.format.html">IntlDateFormatter::format</a> — Format the date/time value as a string</li><li><a href="intldateformatter.formatobject.html">IntlDateFormatter::formatObject</a> — Formats an object</li><li><a href="intldateformatter.getcalendar.html">IntlDateFormatter::getCalendar</a> — Get the calendar type used for the IntlDateFormatter</li><li><a href="intldateformatter.getdatetype.html">IntlDateFormatter::getDateType</a> — Get the datetype used for the IntlDateFormatter</li><li><a href="intldateformatter.geterrorcode.html">IntlDateFormatter::getErrorCode</a> — Get the error code from last operation</li><li><a href="intldateformatter.geterrormessage.html">IntlDateFormatter::getErrorMessage</a> — Get the error text from the last operation.</li><li><a href="intldateformatter.getlocale.html">IntlDateFormatter::getLocale</a> — Get the locale used by formatter</li><li><a href="intldateformatter.getpattern.html">IntlDateFormatter::getPattern</a> — Get the pattern used for the IntlDateFormatter</li><li><a href="intldateformatter.gettimetype.html">IntlDateFormatter::getTimeType</a> — Get the timetype used for the IntlDateFormatter</li><li><a href="intldateformatter.gettimezoneid.html">IntlDateFormatter::getTimeZoneId</a> — Get the timezone-id used for the IntlDateFormatter</li><li><a href="intldateformatter.getcalendarobject.html">IntlDateFormatter::getCalendarObject</a> — Get copy of formatterʼs calendar object</li><li><a href="intldateformatter.gettimezone.html">IntlDateFormatter::getTimeZone</a> — Get formatterʼs timezone</li><li><a href="intldateformatter.islenient.html">IntlDateFormatter::isLenient</a> — Get the lenient used for the IntlDateFormatter</li><li><a href="intldateformatter.localtime.html">IntlDateFormatter::localtime</a> — Parse string to a field-based time value</li><li><a href="intldateformatter.parse.html">IntlDateFormatter::parse</a> — Parse string to a timestamp value</li><li><a href="intldateformatter.setcalendar.html">IntlDateFormatter::setCalendar</a> — Sets the calendar type used by the formatter</li><li><a href="intldateformatter.setlenient.html">IntlDateFormatter::setLenient</a> — Set the leniency of the parser</li><li><a href="intldateformatter.setpattern.html">IntlDateFormatter::setPattern</a> — Set the pattern used for the IntlDateFormatter</li><li><a href="intldateformatter.settimezoneid.html">IntlDateFormatter::setTimeZoneId</a> — Sets the time zone to use</li><li><a href="intldateformatter.settimezone.html">IntlDateFormatter::setTimeZone</a> — Sets formatterʼs timezone</li></ul> </div> <hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="intltimezone.usedaylighttime.html">IntlTimeZone::useDaylightTime</a></div> <div class="next" style="text-align: right; float: right;"><a href="intldateformatter.create.html">IntlDateFormatter::create</a></div> <div class="up"><a href="book.intl.html">intl</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>