user1559230
user1559230

Reputation: 2821

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

Upvotes: 1

Views: 437

Answers (2)

Alex Pliutau
Alex Pliutau

Reputation: 21937

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();

Upvotes: 1

Luke Mills
Luke Mills

Reputation: 1606

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.

Upvotes: 0

Related Questions