常用

  1. //获取UTC格式时间 2019-04-23T10:19:21+08:00
  2. date(DATE_ATOM);
  3. //本日
  4. $today_start_int = strtotime(date('Y-m-d'));
  5. $today_end_int = strtotime("+1 day");
  6. //本周
  7. $week_start_int = strtotime("this week Mon");
  8. $week_end_int = strtotime("this week Sun");
  9. //本月
  10. $month_start_int = strtotime(date('Y-m-01'));
  11. $month_end_int = strtotime(date('Y-m-01')." +1 month");
  1. /*
  2. * 获取前N个月的间隔时间戳
  3. * @param int $i 前N个月,0表示当前月
  4. * @return array $ret
  5. * */
  6. function get_month_arr($i=11){
  7. $ret = [];
  8. for(;$i>=0;$i--){
  9. $month = strtotime("-{$i} month");
  10. $year_month = date('Y-m',$month);
  11. $month_start = (date('Y-m-d',strtotime($year_month)));
  12. $month_end = (date('Y-m-d',strtotime($year_month.' +1 month')));
  13. $ret[] = [$month_start,$month_end];
  14. }
  15. return $ret;
  16. }