ZF-9085: Zend_Date#getMonth() breaks when using PHP date format mode


Just upgraded to 1.10.0 and found this regression.

To reproduce:

1) Set Zend_Date's date format to 'php' 2) Create a new date object 3) Call getMonth() on that date object

Expected result:

Get a date object returned with the month set to the same month as the original date.

Actual result:

Zend_Date_Exception is thrown.

I will add more details in the comments.


Here's a quick test case. Sorry I'm not a regular developer for ZF, so I don't know what kinds of tests you usually submit. My test includes a bootstrap for my own project, but other than that it should be portable:


// This is our project bootstrap... sets up class loading, etc.
require_once(realpath(dirname(__FILE__) . '/FismaUnitTest.php'));

 * Zend_Date fails on getMonth() when the date format mode is 'php'
class ZfDateFailure extends PHPUnit_Framework_TestCase
    public function testGetMonth()
        Zend_Date::setOptions(array('format_type' => 'php'));
        $today = new Zend_Date();

Here are the test results:

/Users/mehaase/openfisma_trunk/tests $ phpunit ZfDateFailure.php
PHPUnit 3.4.4 by Sebastian Bergmann.


Time: 0 seconds

There was 1 error:

1) ZfDateFailure::testGetMonth
Zend_Date_Exception: No date part in 'MMMMMM' found.


Tests: 1, Assertions: 0, Errors: 1.

Fixed with r20936