Zend_Date() is not giving the correct/expected result

439 Views Asked by At

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

2

There are 2 best solutions below

2
Alex Pliutau On BEST ANSWER

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();
1
Luke Mills On

What is the code you are using to call the function?

Different countries use different date formats. Some use dd/mm/yyyy others use mm/dd/yyyy. The order you are passing in the day and month are different from the way the function expects to be called.

Try reversing the month and day before you call the function.