private $current_time;
private $current_day;
private $current_mouth;
private $current_year;
private $current_mouth_last_day;
public function __construct(StatisticsService $statisticsService)
{
$this->statisticsService = $statisticsService;
$this->current_time = time();
$this->current_day = date('d', $this->current_time);
$this->current_mouth = date('m', $this->current_time);
$this->current_year = date('Y', $this->current_time);
$this->current_mouth_last_day = date('t');
}
public function project_contrast()
{
if (request()->isGet()) {
try{
} catch (\Exception $e) {
$result = self::$param_error;
$result['msg'] = $e->getMessage();
$result['line'] = $e->getLine();
$result['file'] = $e->getFile();
return json()->data($result);
}
} else {
$result = $this->return_code(self::$error);
return json()->data($result);
}
}
public function get_this_day_start_end_time()
{
$this_data_start_end_time['start_time'] = strtotime('Y-m-d', $this->current_time);
$this_data_start_end_time['end_time'] = $this_data_start_end_time['start_time']+60*60*24-1;
return $this_data_start_end_time;
}
public function get_this_week_day_start_end_time()
{
$time = date('d',strtotime('last Monday', $this->current_time));
for ($i = 0;$i<=7;$i++) {
$is = $time+$i;
$current_day = $this->current_year.'-'.$this->current_mouth.'-'.$is;
$this_week_day_start_end_time[$i] = [
'start_time' => strtotime($current_day),
'end_time' => strtotime($current_day)+60*60*24-1,
];
}
return $this_week_day_start_end_time;
}
public function get_this_mouth_day_start_end_time()
{
for ($i = 1;$i<= $this->current_mouth_last_day ;$i++) {
$this_mouth_all_day[$i]['start_time'] = mktime(00, 00, 00, $this->current_mouth, $i);
$this_mouth_all_day[$i]['end_time'] = mktime(23, 59, 59, $this->current_mouth, $i);
}
return $this_mouth_all_day;
}
public function get_this_week_start_end_time()
{
$time = strtotime('last Monday', $this->current_time);
$this_week_start_end_time['start_time'] = date('Y-m-d 00:00:00', $time);
$this_week_start_end_time['end_time'] = date('Y-m-d 23:59:59', strtotime('Sunday', $time));
return $this_week_start_end_time;
}
public function get_this_mouth_week_start_end_time()
{
for ($i = 1;$i<= $this->current_mouth_last_day;$i++) {
$this_mouth_all_day[$i]['start_time'] = mktime(00, 00, 00, $this->current_mouth, $i);
$this_mouth_all_day[$i]['end_time'] = mktime(23, 59, 59, $this->current_mouth, $i);
}
return $this_mouth_all_day;
}
public function get_this_mouth_start_end_time()
{
$this_mouth_start_end_time['start_time'] = mktime(0,0,0,date('m'),1,date('Y'));
$this_mouth_start_end_time['end_time'] = mktime(23,59,59,date('m'),date('t'),date('Y'));
return $this_mouth_start_end_time;
}
public function get_this_year_mouth_start_end_time()
{
for ($i = 1;$i <= 12;$i++) {
$this_year_mouth_start_end_time[$i]['start_time']=mktime(00, 00, 00, date($i, strtotime($current_time)), 01);
$this_year_mouth_start_end_time[$i]['end_time']=mktime(23, 59, 59, date($i, strtotime($current_time))+1, 00);
}
return $this_year_mouth_start_end_time;
}
public function get_this_year_quarter_start_end_time()
{
for($i = 1;$i <= 4;$i++)
{
$this_year_quarter_start_end_time[$i]['start_time']=mktime(0, 0, 0,$i*3-3+1,1,date('Y'));
$this_year_quarter_start_end_time[$i]['end_time']=mktime(23,59,59,$i*3,date('t',mktime(0, 0 , 0,1*3,1,date("Y"))),date('Y'));
}
return $this_year_quarter_start_end_time;
}