---- - 2009-07-10 09:04:01
I teste this code with your class
.............
$data1="2001-10-12";
$data2="26-02-1985";
$sd= new simpledatetime();
$arr=$sd->parseDate("Y-m-d",$data1);
print_r($arr);
if(is_null($arr["Hour"])){
echo "no hour";
}
$arr=$sd->parseDate("d-m-Y",$data2);
print_r($arr);
if(is_null($arr["Hour"])){
echo "no hour";
}
echo $sd->Format("d-m-Y","Y-m-d",$data1);
echo $sd->Format("Y/m/d","d-m-Y",$data2);
.....
so I discovered that the are no values stored in Hour , Minutes Second, anyway store a 0h:0m:0s can be useful to avoid problem.
so i modded your class editing the end return of parseDate
//set unset value
if(is_null($resultvar["Hour"])) {
$resultvar["Hour"]=0;
}
if(is_null($resultvar["Minute"])) {
$resultvar["Minute"]=0;
}
if(is_null($resultvar["Second"])) {
$resultvar["Second"]=0;
}
if(is_null($resultvar["Year"])) {
$resultvar["Year"]=2000;
}
if(is_null($resultvar["Month"])) {
$resultvar["Month"]=01;
}
if(is_null($resultvar["Day"])) {
$resultvar["Day"]=01;
}
return ($localize)?$this->Localize($resultvar):$resultvar;