日期时间对象diff返回不明确的结果

I am facing an interesting problem in php. In my project, for calculating date difference i am using date time object diff method. The problem is, in two script for common case the program return different result. I don't understand what is the reason for the scenario. Here is the code snippet.

$DTObj = new DateTime();
$pdate = DateTime::createFromFormat("ymd", 141118);
$diff = $DTObj->diff($pdate);
$dday = $diff->format("%a");
print_r($dday);

In one script it return 4 and another script return 5. Note: My system time 2014-11-23. I highly appreciate any idea for solving this problem. Thanks in advance.

查看全部
dongxiaolin2801
dongxiaolin2801
2014/12/07 06:15
  • datetime
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复