{"id":9226,"date":"2024-05-07T18:01:02","date_gmt":"2024-05-07T10:01:02","guid":{"rendered":""},"modified":"2024-05-07T18:01:02","modified_gmt":"2024-05-07T10:01:02","slug":"PHP \u83b7\u53d6\u672c\u5468\u4e00\u548c\u4e0b\u5468\u4e00\u7684\u65f6\u95f4\uff0c\u83b7\u53d6\u4e00\u5468\u7684\u5f00\u59cb\u65f6\u95f4\u548c\u7ed3\u675f\u65f6\u95f4","status":"publish","type":"post","link":"https:\/\/mushiming.com\/9226.html","title":{"rendered":"PHP \u83b7\u53d6\u672c\u5468\u4e00\u548c\u4e0b\u5468\u4e00\u7684\u65f6\u95f4\uff0c\u83b7\u53d6\u4e00\u5468\u7684\u5f00\u59cb\u65f6\u95f4\u548c\u7ed3\u675f\u65f6\u95f4"},"content":{"rendered":"

  date('Y-m-d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600)); \/\/\u83b7\u53d6\u672c\u5468\u4e00\u7684\u65f6\u95f4
 
  date('Y-m-d',strtotime('+1 week last monday'));\/\/\u83b7\u53d6\u4e0b\u5468\u4e00\u7684\u65f6\u95f4<\/p>\n

  function get_week($time = '', $format='Y-m-d'){
\n
        $time = $time != '' ? $time : time();
        \/\/\u83b7\u53d6\u5f53\u524d\u5468\u51e0
        $week = date('w', $time);
        $weekname = array('\u5468\u4e00','\u5468\u4e8c','\u5468\u4e09','\u5468\u56db','\u5468\u4e94','\u5468\u516d','\u5468\u65e5');
        \/\/\u661f\u671f\u65e5\u6392\u5230\u672b\u4f4d
        if(empty($week)){
\n
            $week=7;
        }
        $date = [];
        for ($i=0; $i<7; $i++){
\n
            $date_time = date($format ,strtotime( '+' . $i+1-$week .' days', $time));
            $date[$i]['date'] = $date_time;
            $date[$i]['time'] = strtotime($date_time);
            $date[$i]['week'] = $weekname[$i];
        }
        return $date;
    }
    
  print_r(get_week(strtotime('2019-12-02'),'Y-m-d'));<\/p>\n","protected":false},"excerpt":{"rendered":"PHP \u83b7\u53d6\u672c\u5468\u4e00\u548c\u4e0b\u5468\u4e00\u7684\u65f6\u95f4\uff0c\u83b7\u53d6\u4e00\u5468\u7684\u5f00\u59cb\u65f6\u95f4\u548c\u7ed3\u675f\u65f6\u95f4date('Y-m-d',(time()-((date('w')==0?7:date('w'))-1)*24*3600...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/9226"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=9226"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/9226\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=9226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=9226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=9226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}