时间函数date(),mktime(),strtotime()

$begin_time = '2018-8';
//指定月份月初时间戳
$month_start = strtotime($begin_time);
//指定月份月末时间戳
$month_end = mktime(23, 59, 59, date('m', strtotime($begin_time))+1, 00);

//获取本周是第几周
$date = date('Y-m-d',time());
$date_week = date("W", strtotime($date));   //本周日期是第几周
$week_num = date("w", strtotime($date));     //本周日期是星期几

//获取前一天的时间:
$mytime= date("Y-m-d H:i:s", strtotime("-1 day"));

//获取三天前的时间:
$mytime= date("Y-m-d H:i:s", strtotime("-3 day"));

//获取前一个月的时间:
$mytime= date("Y-m-d H:i:s", strtotime("-1 month"));

//获取前3个月的时间:
$mytime= date("Y-m-d H:i:s", strtotime("-3 month"));

//获取前一个小时的时间:
$mytime= date("Y-m-d H:i:s", strtotime("-1 hour"));

//获取前一年的时间:
$mytime= date("Y-m-d H:i:s", strtotime("-1 year"));

//获取本月16日的时间戳
$end_time = strtotime(date('Y-m-16')); //结束是间 本月16日

//获取上个月16日的时间戳
$yesterday = strtotime(date('Y-m-16',strtotime('-1month‘)));

 

posted @ 2018-09-15 23:24  好笑。  阅读(265)  评论(0编辑  收藏  举报