Php 国际日期格式化失败
我正在尝试使用DateTime的一个子项来扩展DateTime的功能,用于国际格式和简单的数据库格式。但它不适用于负数日期<“我的日期”对象的“代码>变量转储”向我显示以下内容:Php 国际日期格式化失败,php,date,datetime,Php,Date,Datetime,我正在尝试使用DateTime的一个子项来扩展DateTime的功能,用于国际格式和简单的数据库格式。但它不适用于负数日期变量转储”向我显示以下内容: 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=
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')
工作正常,但不能与IntlDateFormatter一起使用。
这是我的代码:
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'));
}
}
编辑:导致失败的是新日期('0000-00-00')
。它到底是如何“失败”的?之后是白色页面/没有输出