从当前日期起3天和4天不起作用

时间:2014-02-15 09:27:46

标签: php date strtotime

这真的很简单,我正在搞乱一些事情,目前它与日期有关......所以我有这个......

$day = date('d',strtotime("+0 days"));
$month = date('M',strtotime("+0 days"));
$year = date('Y',strtotime("+0 days"));
$date = $day.'/'.$month.'/'.$year;

$echo $date;

这没有问题。但是当它试图从它中添加/外卖时,它就是乱搞,那就是我遇到问题。当我做这个..

$day = date('d',strtotime("+1 days"));
$month = date('M',strtotime("+1 days"));
$year = date('Y',strtotime("+1 days"));
$date = $day.'/'.$month.'/'.$year;
再次,我知道问题,我可以添加如何每隔多天,从来没有问题,当我带走了几天,我可以采取1,2,5,6,7,8,9等等..几天之后,但是试着花3到4天的时间,比如......

$day = date('d',strtotime("-3 days"));
$month = date('M',strtotime("-3 days"));
$year = date('Y',strtotime("-3 days"));
$date = $day.'/'.$month.'/'.$year;

它不需要那么多天,它只需要离当前日期1。任何人都可以解释为什么会这样吗?为什么我不能拿3&目前约会4天?

1 个答案:

答案 0 :(得分:0)

试试这个

$now = date("d/M/Y");
$newDate = date("d/M/Y", strtotime('-3 day'.$now));

你可以在一行以上的地方完成所有工作,而不是分别花几天,几个月。