Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 国际日期格式化失败_Php_Date_Datetime - Fatal编程技术网

Php 国际日期格式化失败

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=

我正在尝试使用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=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')

它到底是如何“失败”的?之后是白色页面/没有输出