PHP比较当前年度和去年的数字

时间:2016-07-21 03:53:43

标签: php

我有这个代码,我如何减去1年来显示去年确切的数字。

例如:2016-1-1与2015-1-1相比。

 $weekno = date('W', strtotime($mthyr.'-'.$j));
    $lastyear = date('Y', strtotime($mthyr.'-'.$j)) - 1;
    $dayinno = date('N', strtotime($mthyr.'-'.$j));
    $gendate = new DateTime();
    $gendate->setISODate($lastyear,$weekno,$dayinno); //year , week num , day
    $lydate = $gendate->format('Ymd');

1 个答案:

答案 0 :(得分:0)

如果这总是你想要的日期格式,那怎么样?

min-width
相关问题