美文网首页
php获取指定日期

php获取指定日期

作者: 凌乱秋天 | 来源:发表于2017-07-28 22:37 被阅读0次
/**
 php获取指定日期的前一天,前一月,前一年日期
*/

$time = "2017-7-28";        //特定时间

echo "前一天的日期为". date("Y-m-d",strtotime("-1 days",$time))."</br>";

echo "前一月的日期为". date("Y-m-d",strtotime("-1 months",$time))."</br>";

echo "前一年的日期为". date("Y-m-d",strtotime("-1 years",$time))."</br>";


//如果是后一天,后一年,后一个月的日期

echo "后一天的日期为". date("Y-m-d",strtotime("+1 days",$time))."</br>";

echo "后一月的日期为". date("Y-m-d",strtotime("+1 months",$time))."</br>";

echo "后一年的日期为". date("Y-m-d",strtotime("+1 years",$time))."</br>";

//如果不是1,就把+1或者-1换成+n或者-n就可以了。

相关文章

网友评论

      本文标题:php获取指定日期

      本文链接:https://www.haomeiwen.com/subject/umtqlxtx.html