PHP 获取当天凌晨时间戳

总结几种PHP 获取当天凌晨时间戳方法:

首先设置时区:

header("Content-type:text/html;charset=utf-8");
 
//设置北京时间为默认时区
date_default_timezone_set('PRC');

方法一:

//当天的起始时间戳 
$beginToday = mktime(0,0,0,date('m'),date('d'),date('Y')); 

方法二:

//当天凌晨时间戳
strtotime(date('Y-m-d'));

方法三:

//当天凌晨0点的时间戳
strtotime(date('Y-m-d',strtotime('0 day')));

方法四:

//当日时间戳
strtotime(date("Y-m-d"),time());

 

你可能感兴趣的:(php)