I am trying with a child of DateTime to extend the functionality of DateTime for international formatting and simple database formatting. But it does not work with negative Date. var_dump
of my Date object shows me the following:
object(Date)[98]
public 'date' => string '-0001-11-30 00:00:00' (length=20)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Paris' (length=12)
$this->format('Y-m-d')
works fine, but not with IntlDateFormatter
.
This is my Code:
class Date extends DateTime
{
public function __toString()
{
$fmt = new IntlDateFormatter(Locale::getDefault(), IntlDateFormatter::MEDIUM, IntlDateFormatter::MEDIUM);
return $fmt->format($this);
}
public function toSqlDate()
{
return new String($this->format('Y-m-d H:i:s'));
}
}
Edit: It´s new Date('0000-00-00')
which causes the fail.