Hello,
I use a Date field in Silverstripe and i know Silverstripe 2.4.0 use Zend_Date. But i think there is a problem with dates 1848-02-** and Zend_Date : when i display these dates, Zend_Date add +1 day each time !?
I try this code to show the problem (i think it's not a silverstripe problem) :
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
</head>
<body>
<?php
require_once 'Zend/Date.php';
$frDates = array(
"31/01/1848",
"01/02/1848",
"02/02/1848",
"03/02/1848",
"01/03/1848"
);
$dates = array(
"1848-01-31",
"1848-02-01",
"1848-02-02",
"1848-02-03",
"1848-03-01"
);
date_default_timezone_set('Europe/Paris');
print "<h1>Zend_Date (Zend Framework with Silverstripe 2.4.0)</h1>";
foreach($dates as $index => $date) {
$oDate = new Zend_Date($date);
$stroDate = $oDate->get('dd/MM/yyyy');
$test = ($frDates[$index] !== $stroDate);
$style = ($test ? ' style="color:red;" ' : '');
$sign = ($test ? '!=' : '=');
print "<div $style >" . $frDates[$index] . " $sign $stroDate</div>";
}
print "<h1>Test avec DateTime (PHP version " . phpversion() . ")</h1>";
foreach($dates as $index => $date) {
$oDate = new DateTime($date);
$stroDate = $oDate->format('d/m/Y');
$test = ($frDates[$index] !== $stroDate);
$style = ($test ? ' style="color:red;" ' : '');
$sign = ($test ? '!=' : '=');
print "<div $style >" . $frDates[$index] . " $sign $stroDate</div>";
}
?>
</body>
</html>
And the result :
Zend_Date (Zend Framework with Silverstripe 2.4.0)
31/01/1848 = 31/01/1848
*01/02/1848 != 02/02/1848
*02/02/1848 != 03/02/1848
*03/02/1848 != 04/02/1848
01/03/1848 = 01/03/1848
Test avec DateTime (PHP version 5.2.6-1+lenny8)
31/01/1848 = 31/01/1848
01/02/1848 = 01/02/1848
02/02/1848 = 02/02/1848
03/02/1848 = 03/02/1848
01/03/1848 = 01/03/1848
Snirf :'(
A solution ?