<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect2 id="zend.validate.set.date">
    <title>Date</title>

    <para>
        <classname>Zend_Validate_Date</classname> allows you to validate if a given value contains
        a date. This validator validates also localized input.
    </para>

    <sect3 id="zend.validate.set.date.options">
        <title>Supported options for Zend_Validate_Date</title>

        <para>
            The following options are supported for <classname>Zend_Validate_Date</classname>:
        </para>

        <itemizedlist>
            <listitem>
                <para>
                    <emphasis><property>format</property></emphasis>: Sets the format which is used
                    to write the date.
                </para>
            </listitem>

            <listitem>
                <para>
                    <emphasis><property>locale</property></emphasis>: Sets the locale which will be
                    used to validate date values.
                </para>
            </listitem>
        </itemizedlist>
    </sect3>

    <sect3 id="zend.validate.set.date.basic">
        <title>Default date validation</title>

        <para>
            The easiest way to validate a date is by using the default date format. It is used when
            no locale and no format has been given.
        </para>

        <programlisting language="php"><![CDATA[
$validator = new Zend_Validate_Date();

$validator->isValid('2000-10-10');   // returns true
$validator->isValid('10.10.2000'); // returns false
]]></programlisting>

        <para>
            The default date format for <classname>Zend_Validate_Date</classname> is 'yyyy-MM-dd'.
        </para>
    </sect3>

    <sect3 id="zend.validate.set.date.localized">
        <title>Localized date validation</title>

        <para>
            <classname>Zend_Validate_Date</classname> validates also dates which are given in a
            localized format. By using the <property>locale</property> option you can define the
            locale which the date format should use for validation.
        </para>

        <programlisting language="php"><![CDATA[
$validator = new Zend_Validate_Date(array('locale' => 'de'));

$validator->isValid('10.Feb.2010'); // returns true
$validator->isValid('10.May.2010'); // returns false
]]></programlisting>

        <para>
            The <property>locale</property> option sets the default date format. In the above
            example this is 'dd.MM.yyyy' which is defined as default date format for 'de'.
        </para>
    </sect3>

    <sect3 id="zend.validate.set.date.formats">
        <title>Self defined date validation</title>

        <para>
            <classname>Zend_Validate_Date</classname> supports also self defined date formats.
            When you want to validate such a date you can use the <property>format</property>
            option.
        </para>

        <programlisting language="php"><![CDATA[
$validator = new Zend_Validate_Date(array('format' => 'yyyy'));

$validator->isValid('2010'); // returns true
$validator->isValid('May');  // returns false
]]></programlisting>

        <para>
            Of course you can combine <property>format</property> and <property>locale</property>.
            In this case you can also use localized month or daynames.
        </para>

        <programlisting language="php"><![CDATA[
$validator = new Zend_Validate_Date(array('format' => 'yyyy MMMM', 'locale' => 'de'));

$validator->isValid('2010 Dezember'); // returns true
$validator->isValid('2010 June');     // returns false
]]></programlisting>
    </sect3>
</sect2>
<!--
vim:se ts=4 sw=4 et:
-->
