Bug in Zend_Date? When I try to store Zend_Date objects into an array, using a
while to create a range of dates, when I print the array is the same last
object per array element, but why ? the array keys are consecutives, I try with
a counter as key and doesn't work either, finally I fix it creating a new
object per iteration, but I don't know if something is wrong with my code, this
what I'm doing:
$objDateStartMin = new Zend_Date( "2008-08-12 00:00:00" );
$objDateEndMax = new Zend_Date( "2008-09-26 00:00:00" );
$arrDateObjects = array();
while ( $objDateEndMax->isLater( $objDateStartMin ) )
{
// When I store the object in the array in the final array just appear the
last iteration for all array elements.
$arrDateObjects[] = $objDateStartMin->addDay( 1 );
// Ugly fix.
// $arrDateObjects[] = new Zend_Date( $objDateStartMin->addDay( 1 ) );
}
// When I print the array of object is the same last object of the iteration,
look the timestamp, same for all array elements.
array(45) {
[0] => object(Zend_Date)#53 (8) {
["_Locale:private"] => object(Zend_Locale)#28 (2) {
["_Locale:private"] => string(5) "es_ES"
["_Codeset:private"] => NULL
}
["_Fractional:private"] => int(0)
["_Precision:private"] => int(3)
["_unixTimestamp:private"] => string(10) "1222401600"
["_timezone:private"] => string(16) "America/New_York"
["_offset:private"] => int(18000)
["_syncronised:private"] => int(0)
["_dst:protected"] => bool(true)
}
[1] => object(Zend_Date)#53 (8) {
["_Locale:private"] => object(Zend_Locale)#28 (2) {
["_Locale:private"] => string(5) "es_ES"
["_Codeset:private"] => NULL
}
["_Fractional:private"] => int(0)
["_Precision:private"] => int(3)
["_unixTimestamp:private"] => string(10) "1222401600"
["_timezone:private"] => string(16) "America/New_York"
["_offset:private"] => int(18000)
["_syncronised:private"] => int(0)
["_dst:protected"] => bool(true)
}
[2] => object(Zend_Date)#53 (8) {
["_Locale:private"] => object(Zend_Locale)#28 (2) {
["_Locale:private"] => string(5) "es_ES"
["_Codeset:private"] => NULL
}
["_Fractional:private"] => int(0)
["_Precision:private"] => int(3)
["_unixTimestamp:private"] => string(10) "1222401600"
["_timezone:private"] => string(16) "America/New_York"
["_offset:private"] => int(18000)
["_syncronised:private"] => int(0)
["_dst:protected"] => bool(true)
}
[3] => object(Zend_Date)#53 (8) {
["_Locale:private"] => object(Zend_Locale)#28 (2) {
["_Locale:private"] => string(5) "es_ES"
["_Codeset:private"] => NULL
}
["_Fractional:private"] => int(0)
["_Precision:private"] => int(3)
["_unixTimestamp:private"] => string(10) "1222401600"
["_timezone:private"] => string(16) "America/New_York"
["_offset:private"] => int(18000)
["_syncronised:private"] => int(0)
["_dst:protected"] => bool(true)
}
[4] => object(Zend_Date)#53 (8) {
["_Locale:private"] => object(Zend_Locale)#28 (2) {
["_Locale:private"] => string(5) "es_ES"
["_Codeset:private"] => NULL
}
["_Fractional:private"] => int(0)
["_Precision:private"] => int(3)
["_unixTimestamp:private"] => string(10) "1222401600"
["_timezone:private"] => string(16) "America/New_York"
["_offset:private"] => int(18000)
["_syncronised:private"] => int(0)
["_dst:protected"] => bool(true)
}
[5] => object(Zend_Date)#53 (8) {
["_Locale:private"] => object(Zend_Locale)#28 (2) {
["_Locale:private"] => string(5) "es_ES"
["_Codeset:private"] => NULL
}
["_Fractional:private"] => int(0)
["_Precision:private"] => int(3)
["_unixTimestamp:private"] => string(10) "1222401600"
["_timezone:private"] => string(16) "America/New_York"
["_offset:private"] => int(18000)
["_syncronised:private"] => int(0)
["_dst:protected"] => bool(true)
}
[6] => object(Zend_Date)#53 (8) {
["_Locale:private"] => object(Zend_Locale)#28 (2) {
["_Locale:private"] => string(5) "es_ES"
["_Codeset:private"] => NULL
}
["_Fractional:private"] => int(0)
["_Precision:private"] => int(3)
["_unixTimestamp:private"] => string(10) "1222401600"
["_timezone:private"] => string(16) "America/New_York"
["_offset:private"] => int(18000)
["_syncronised:private"] => int(0)
["_dst:protected"] => bool(true)
}
[7] => object(Zend_Date)#53 (8) {
["_Locale:private"] => object(Zend_Locale)#28 (2) {
["_Locale:private"] => string(5) "es_ES"
["_Codeset:private"] => NULL
}
["_Fractional:private"] => int(0)
["_Precision:private"] => int(3)
["_unixTimestamp:private"] => string(10) "1222401600"
["_timezone:private"] => string(16) "America/New_York"
["_offset:private"] => int(18000)
["_syncronised:private"] => int(0)
["_dst:protected"] => bool(true)
}
[8] => object(Zend_Date)#53 (8) {
["_Locale:private"] => object(Zend_Locale)#28 (2) {
["_Locale:private"] => string(5) "es_ES"
["_Codeset:private"] => NULL
}
["_Fractional:private"] => int(0)
["_Precision:private"] => int(3)
["_unixTimestamp:private"] => string(10) "1222401600"
["_timezone:private"] => string(16) "America/New_York"
["_offset:private"] => int(18000)
["_syncronised:private"] => int(0)
["_dst:protected"] => bool(true)
}
[9] => object(Zend_Date)#53 (8) {
["_Locale:private"] => object(Zend_Locale)#28 (2) {
["_Locale:private"] => string(5) "es_ES"
["_Codeset:private"] => NULL
}
["_Fractional:private"] => int(0)
["_Precision:private"] => int(3)
["_unixTimestamp:private"] => string(10) "1222401600"
["_timezone:private"] => string(16) "America/New_York"
["_offset:private"] => int(18000)
["_syncronised:private"] => int(0)
["_dst:protected"] => bool(true)
}
[10] => object(Zend_Date)#53 (8) {
["_Locale:private"] => object(Zend_Locale)#28 (2) {
["_Locale:private"] => string(5) "es_ES"
["_Codeset:private"] => NULL
}
["_Fractional:private"] => int(0)
["_Precision:private"] => int(3)
["_unixTimestamp:private"] => string(10) "1222401600"
["_timezone:private"] => string(16) "America/New_York"
["_offset:private"] => int(18000)
["_syncronised:private"] => int(0)
["_dst:protected"] => bool(true)
}
[11] => object(Zend_Date)#53 (8) {
["_Locale:private"] => object(Zend_Locale)#28 (2) {
["_Locale:private"] => string(5) "es_ES"
["_Codeset:private"] => NULL
}
["_Fractional:private"] => int(0)
["_Precision:private"] => int(3)
["_unixTimestamp:private"] => string(10) "1222401600"
["_timezone:private"] => string(16) "America/New_York"
["_offset:private"] => int(18000)
["_syncronised:private"] => int(0)
["_dst:protected"] => bool(true)
}
[12] => object(Zend_Date)#53 (8) {
["_Locale:private"] => object(Zend_Locale)#28 (2) {
["_Locale:private"] => string(5) "es_ES"
["_Codeset:private"] => NULL
}
["_Fractional:private"] => int(0)
["_Precision:private"] => int(3)
["_unixTimestamp:private"] => string(10) "1222401600"
["_timezone:private"] => string(16) "America/New_York"
["_offset:private"] => int(18000)
["_syncronised:private"] => int(0)
["_dst:protected"] => bool(true)
...