PHP strtotime函数参数

定义和用法 strtotime() 
strtotime() 函数将任何英文文本的日期时间描述解析为 Unix 时间戳。
语法 
strtotime(time,now)

 

//获取当前时间戳
echo strtotime("now");
echo date('Y-m-d H:i:s', strtotime("now"));
//获取指定的时间戳
echo strtotime("2015-06-11 10:11:00");
echo date('Y-m-d H:i:s', strtotime("2015-06-11 10:11:00"));
//获取指定的时间戳[等同于strtotime("2005-10-03")]
echo strtotime("3 October 2005");
echo date('Y-m-d H:i:s', strtotime("3 October 2005"));
//当前时间加五个小时
echo strtotime("+5 hours");
echo date('Y-m-d H:i:s', strtotime("+5 hours"));
//当前时间加1天
echo strtotime("+1 day");
echo date('Y-m-d H:i:s', strtotime("+1 day"));
//当前时间加多天
echo strtotime("+2 days");
echo date('Y-m-d H:i:s', strtotime("+2 days"));
//当前时间加 1周 3天 7小时 5秒
echo strtotime("+1 week 3 days 7 hours 5 seconds");
echo date('Y-m-d H:i:s', strtotime("+1 week 3 days 7 hours 5 seconds"));
//当前时间下一个周一
echo strtotime("next Monday");
echo date('Y-m-d H:i:s', strtotime("next Monday"));
//当前时间前一个周日
echo strtotime("last Sunday");
echo date('Y-m-d H:i:s', strtotime("last Sunday"));
//给定时间 减去一天
echo strtotime("-1 day",strtotime("2018-07-01 10:11:00"));
echo date('Y-m-d H:i:s', strtotime("-1 day",strtotime("2018-07-01 10:11:00")));

 

你可能感兴趣的:(php)