日期转时间戳
mktime($hour,$minute,$second,$month,$day,$year);
# 例子:
echo mktime(0,0,0,6,7,2017); //2017年6月7日00:00:00
>> 1496764800
strtotime($date);
# 例子:
echo strtotime('2017-6-7 00:00:00'); //2017年6月7日00:00:00
>> 1496764800
对日期进行加减
// 当前时间加一个月
strtotime('+1 month');
// 当前时间减一个月
strtotime('-1 month');
// 当前时间加一年
strtotime('+1 year');
>> 以上均返回时间戳
# 例子:返回最近三个月的月份
echo date("Ym",strtotime(date('Ym').' -1 month')); //上一月
echo date("Ym",strtotime(date('Ym').' -2 month')); //上两月
echo date("Ym",strtotime(date('Ym').' -3 month')); //上三月