[TOC] ``` date_default_timezone_set('PRC'); class FormDate { protected $interval=1; /** * 今天开始 * @return false|int 格式 时间戳 */ static public function startDay(){ return mktime(0,0,0,date('m'),date('d'),date('Y')); } /** * 今天开始 * @return false|int 格式 2018-05-08 00:00:00 */ static public function stratDayFormat(){ return date('Y-m-d H:i:s',self::startDay()); } /** * 今天结束 * @return false|int 格式 时间戳 */ static public function endDay(){ return mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1; } /** * 今天结束 * @return false|int 格式 2018-06-01 23:59:59 */ static public function endDayFormat(){ return date('Y-m-d H:i:s',(self::endDay())); } /** * 提前几天 * @param $day * @return false|int 时间戳 */ static public function forwardDay($day){ return mktime(0,0,0,date('m'),date('d')-$day,date('Y')); } /** * 提前几天 * @param $day * @return false|string 2018-05-09 00:00:00 */ static public function forwardDayFormat($day){ return date('Y-m-d H:i:s',self::forwardDay($day)); } /** * 几天后 * @param $day * @return false|int 时间戳 */ static public function afterDay($day){ return mktime(0,0,0,date('m'),date('d')+1+$day,date('Y'))-1; } /** * 几天后 * @param $day * @return false|string 2018-05-13 23:59:59 */ static public function afterDayFormat($day){ return date('Y-m-d H:i:s',self::afterDay($day)); } } //今天开始 print_r(FormDate::startDay().PHP_EOL);//1525968000 print_r(FormDate::stratDayFormat().PHP_EOL);//2018-05-11 00:00:00 //今天结束 print_r(FormDate::endDay().PHP_EOL);//1526054399 print_r(FormDate::endDayFormat().PHP_EOL);//2018-05-11 23:59:59 //几天前开始 print_r(FormDate::forwardDay(2).PHP_EOL);//1525795200 print_r(FormDate::forwardDayFormat(2).PHP_EOL);//2018-05-09 00:00:00 //几天后结束 print_r(FormDate::afterDay(2).PHP_EOL);//1526140800 print_r(FormDate::afterDayFormat(2).PHP_EOL);//2018-05-13 23:59:59 ```