Home » Date and Time » Date » Bug #9568
beginOfMonthBySpan - december, shifted one year
Details
| Submitted | 2006-12-07 08:30 UTC |
|---|---|
| From | georgbez at gmx dot net |
| Assigned | firman |
| Status | Closed |
| Package | Date |
| PHP Version | 5.1.1 |
| OS | Win2000 |
| Roadmaps | (Not assigned) |
Comments
[2006-12-07 08:30 UTC] georgbez at gmx dot net
Description:
------------
Hi,
the method beginOfMonthBySpan has an bug. If one takes the months off, comes starting from that second year, always in December a wrong year. It is shifted one year.
Best regards,
Georg Bez
Test script:
---------------
<?php
require_once 'Date/Calc.php';
$tag = date( 'd' );
$out = '';
$date = new Date_Calc();
for ($i = 1; $i <= 40; $i++) {
$von = $date->beginOfMonthBySpan( -($i), null, null, "%d.%m.%Y" );
$von = explode( '.', $von );
$s = $i.' - '.sprintf( "%s.%s.%s", $tag, $von[1], $von[2] );
if( $von[1] == 12 ) {
$out .= '<b>'.$s.'</b>';
} else {
$out .= $s;
}
$out .= "<br>";
}
echo $out;
?>
Actual result:
--------------
12 - 07.12.2005
...
24 - 07.12.2005
...
36 - 07.12.2004
...