<?php
/**
 * [UQcms System] Copyright uqcms.com
 * QQ: 2200631718
 * Author: gj.name
 * This is NOT a freeware
*/
defined('IN_UQ') or exit('Access Denied'); class time_range { static function now_time(){ return time(); } static function today(){ $beginTime = date('Y-m-d 00:00:00', self::now_time()); $endTime = date('Y-m-d 23:59:59', self::now_time()); return array('stime'=>strtotime($beginTime), 'etime'=>strtotime($endTime),'s_time'=>$beginTime, 'e_time'=>$endTime); } static function yesterday(){ $time = strtotime('-1 day', self::now_time()); $beginTime = date('Y-m-d 00:00:00', $time); $endTime = date('Y-m-d 23:59:59', self::now_time()); return array('stime'=>strtotime($beginTime), 'etime'=>strtotime($endTime),'s_time'=>$beginTime, 'e_time'=>$endTime); } static function three_day(){ $time = strtotime('-2 day', $now); $beginTime = date('Y-m-d 00:00:00', $time); $endTime = date('Y-m-d 23:59:59', $now); } static function week(){ $time = '1' == date('w') ? strtotime('Monday', $now) : strtotime('last Monday', $now); $beginTime = date('Y-m-d 00:00:00', $time); $endTime = date('Y-m-d 23:59:59', strtotime('Sunday', $now)); return array('startime'=>$beginTime, 'endtime'=>$endTime); } static function lastweek(){ $thisMonday = '1' == date('w') ? strtotime('Monday', $now) : strtotime('last Monday', $now); $lastMonday = strtotime('-7 days', $thisMonday); $beginTime = date('Y-m-d 00:00:00', $lastMonday); $endTime = date('Y-m-d 23:59:59', strtotime('last sunday', $now)); } static function month(){ $beginTime = date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m', self::now_time()), '1', date('Y', self::now_time()))); $endTime = date('Y-m-d 23:59:59', mktime(0, 0, 0, date('m', self::now_time()), date('t', self::now_time()), date('Y', self::now_time()))); return array('stime'=>strtotime($beginTime), 'etime'=>strtotime($endTime),'s_time'=>$beginTime, 'e_time'=>$endTime); } static function three_month(){ $time = strtotime('-2 month', self::now_time()); $beginTime = date('Y-m-d 00:00:00', mktime(0, 0,0, date('m', $time), 1, date('Y', $time))); $endTime = date('Y-m-d 23:59:59', mktime(0, 0, 0, date('m', self::now_time()), date('t', self::now_time()), date('Y', self::now_time()))); return array('stime'=>strtotime($beginTime), 'etime'=>strtotime($endTime),'s_time'=>$beginTime, 'e_time'=>$endTime); } static function half_year(){ $time = strtotime('-5 month', $now); $beginTime = date('Y-m-d 00:00:00', mktime(0, 0,0, date('m', $time), 1, date('Y', $time))); $endTime = date('Y-m-d 23:59:59', mktime(0, 0, 0, date('m', $now), date('t', $now), date('Y', $now))); } static function year(){ $reduce_time = strtotime('-1 year', self::now_time()); echo date('Y-m-d H:i:s',$reduce_time); $beginTime = date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m', $reduce_time)+1, 1, date('Y', $reduce_time))); $endTime = date('Y-m-d 23:59:59', mktime(0, 0, 0, date('m', self::now_time()), date('t', self::now_time()), date('Y', self::now_time()))); return array('stime'=>strtotime($beginTime), 'etime'=>strtotime($endTime),'s_time'=>$beginTime, 'e_time'=>$endTime); } static function three_year(){ $time = strtotime('-2 year', $now); $beginTime = date('Y-m-d 00:00:00', mktime(0, 0, 0, 1, 1, date('Y', $time))); $endTime = date('Y-m-d 23:59:59', mktime(0, 0, 0, 12, 31, date('Y'))); return array('startime'=>$beginTime, 'endtime'=>$endTime); } }