douqiao7958 2018-05-20 09:59
浏览 116
已采纳

PHP DateTime提供的值不正确

I wonder why this php code gives incorrect output value.

dd(new \DateTime("1397/02/29", new \DateTimeZone('Asia/Tehran')));

It outputs below object:

DateTime @-18076965944 {#1256 ▼
  date: 1397-03-01 00:00:00.0 Asia/Tehran (+03:25)
}

As you see the date is incorrect and must be 1397-02-01. The output for values 1397/02/30 && 1397/02/31 is incorrect also.

Can anyone help please. thanks.

  • 写回答

3条回答 默认 最新

查看更多回答(2条)

报告相同问题?