zend-frameworkzend-date

Zend_Date() is not giving the correct/expected result


Zend_Date function returns the value "Feb 10, 2012" . It supposed to return "Oct 2, 2012". If a give the day greater than 12 than it returns the currect output. I don't know what I was missing. Please help me.

Thanks


Solution

  • If your format is YYYY-MM-DD (2012-10-02), try this code:

    $str  = '2012-10-02';
    $date = new Zend_Date($str, Zend_Date::YEAR . '-' . Zend_Date::MONTH . '-' . Zend_Date::DAY);
    echo $date->toString();