<?php
/** 
 * UQ云商：	www.uqcms.com  
 * 联系QQ：	2200631718 
 * 可免费商用，需要留UQ云商链接作为交换，只首页底部留取即可，不影响使用。
 */

defined('IN_UQ') or exit('Access Denied'); class time_range { static function now_time(){ return time(); } static function today(){ $uq0 = date('Y-m-d 00:00:00', self::now_time()); $uq1 = date('Y-m-d 23:59:59', self::now_time()); return array('stime'=>strtotime($uq0), 'etime'=>strtotime($uq1),'s_time'=>$uq0, 'e_time'=>$uq1); } static function yesterday($uq2 = 0){ $uq3 = strtotime('-1 day', self::now_time()); $uq0 = date('Y-m-d 00:00:00', $uq3); if($uq2 == '1'){ $uq1 = date('Y-m-d 23:59:59', $uq3); }else{ $uq1 = date('Y-m-d 23:59:59', self::now_time()); } return array('stime'=>strtotime($uq0), 'etime'=>strtotime($uq1),'s_time'=>$uq0, 'e_time'=>$uq1); } static function three_day(){ $uq3 = strtotime('-2 day', $uq4); $uq0 = date('Y-m-d 00:00:00', $uq3); $uq1 = date('Y-m-d 23:59:59', $uq4); } static function week(){ $uq3 = '1' == date('w') ? strtotime('Monday', $uq4) : strtotime('last Monday', $uq4); $uq0 = date('Y-m-d 00:00:00', $uq3); $uq1 = date('Y-m-d 23:59:59', strtotime('Sunday', $uq4)); return array('startime'=>$uq0, 'endtime'=>$uq1); } static function lastweek(){ $uq5 = '1' == date('w') ? strtotime('Monday', $uq4) : strtotime('last Monday', $uq4); $uq6 = strtotime('-7 days', $uq5); $uq0 = date('Y-m-d 00:00:00', $uq6); $uq1 = date('Y-m-d 23:59:59', strtotime('last sunday', $uq4)); } static function month(){ $uq0 = date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m', self::now_time()), '1', date('Y', self::now_time()))); $uq1 = 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($uq0), 'etime'=>strtotime($uq1),'s_time'=>$uq0, 'e_time'=>$uq1); } static function last_month(){ $uq0 = date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m', self::now_time()), '1', date('Y', self::now_time()))); $uq1 = 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($uq0), 'etime'=>strtotime($uq1),'s_time'=>$uq0, 'e_time'=>$uq1); } static function three_month(){ $uq3 = strtotime('-2 month', self::now_time()); $uq0 = date('Y-m-d 00:00:00', mktime(0, 0,0, date('m', $uq3), 1, date('Y', $uq3))); $uq1 = 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($uq0), 'etime'=>strtotime($uq1),'s_time'=>$uq0, 'e_time'=>$uq1); } static function half_year(){ $uq3 = strtotime('-5 month', $uq4); $uq0 = date('Y-m-d 00:00:00', mktime(0, 0,0, date('m', $uq3), 1, date('Y', $uq3))); $uq1 = date('Y-m-d 23:59:59', mktime(0, 0, 0, date('m', $uq4), date('t', $uq4), date('Y', $uq4))); } static function year(){ $uq7 = strtotime('-1 year', self::now_time()); echo date('Y-m-d H:i:s',$uq7); $uq0 = date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m', $uq7)+1, 1, date('Y', $uq7))); $uq1 = 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($uq0), 'etime'=>strtotime($uq1),'s_time'=>$uq0, 'e_time'=>$uq1); } static function three_year(){ $uq3 = strtotime('-2 year', $uq4); $uq0 = date('Y-m-d 00:00:00', mktime(0, 0, 0, 1, 1, date('Y', $uq3))); $uq1 = date('Y-m-d 23:59:59', mktime(0, 0, 0, 12, 31, date('Y'))); return array('startime'=>$uq0, 'endtime'=>$uq1); } } 