function getTimeDiff($current_time, $last_time)
{
$current_time_str = strtotime(date("Ymd", $current_time));
$last_time_str = strtotime(date("Ymd", $last_time));
if($current_time_str >= $last_time_str){
$timediff = $current_time_str - $last_time_str;
$days = intval($timediff/86400);
} else {
$days = 0;
}
return $days;
}
function getMonthsInTime($start_month = '',$end_month = ''){
$end_month = $end_month = '' ? date('Y-m') : $end_month;
$start_month = $start_month = '' ? date('Y-m', strtotime('-1 year')) : $start_month;
$time_arr = [];
$begin = new DateTime($start_month);
$end = new DateTime($end_month);
$end = $end->modify('+1 month');
$interval = new DateInterval('P1M');
$daterange = new DatePeriod($begin, $interval ,$end);
foreach($daterange as $date){
$time_arr[] = $date->format("Y-m");
}
return $time_arr;
}
function getEverydayInMonth($month_time)
{
if(!$month_time)
{
$month_time = date('Y-m');
}
$start_time = strtotime($month_time);
$days = date('t', strtotime($month_time));
$date = [];
for($i = 1;$i<=$days;$i++)
{
$date[] = date('Y-m-d',$start_time+(($i-1) * 86400));
}
return $date;
}
function getEveryday($day_number = 7)
{
$seven_day = date("Y-m-d", strtotime("-" . $day_number. " day"));
$stimestamp = strtotime($seven_day);
$etimestamp = strtotime(date("Y-m-d", time()));
$days = ($etimestamp - $stimestamp) / 86400 + 1;
$date = array();
for ($i = 0; $i < $days; $i++) {
$date[] = date('Ymd', $stimestamp + (86400 * $i));
}
return $date;
}
function getMonthsIn($start_month = '', $end_month = '', $time_type = '', $time_name = '')
{
$start_month = strtotime('-1 ' . $time_name, $start_month);
while (($start_month = strtotime('+1 ' . $time_name, $start_month)) <= $end_month) {
$time_arr[] = date($time_type, $start_month);
}
return $time_arr;
}