{"id":351,"date":"2020-09-25T17:18:52","date_gmt":"2020-09-25T09:18:52","guid":{"rendered":"https:\/\/wp.dj47.top\/?p=351"},"modified":"2021-10-20T16:11:04","modified_gmt":"2021-10-20T08:11:04","slug":"%e5%a4%87%e5%bf%98%ef%bc%9aphp%e5%8f%96%e6%97%a5%e6%9c%9f%e7%9b%b8%e5%85%b3%e7%9a%84%e5%88%a4%e6%96%ad","status":"publish","type":"post","link":"https:\/\/www.djlog.cn\/?p=351","title":{"rendered":"\u5907\u5fd8\uff1aPHP\u53d6\u65e5\u671f\u76f8\u5173\u7684\u5224\u65ad"},"content":{"rendered":"<pre class=\"language-php\"><code>if ($altime == \"\u4eca\u65e5\") {\r\n\t$t = time();\r\n\t$first = date('Y-m-d H:i:s', mktime(0, 0, 0, date(\"m\", $t), date(\"d\", $t), date(\"Y\", $t)));\r\n\t\/\/ \u5f53\u5929\u5f00\u59cb\u65f6\u95f4\r\n\t$last = date('Y-m-d H:i:s', mktime(23, 59, 59, date(\"m\", $t), date(\"d\", $t), date(\"Y\", $t)));\r\n\t\/\/ \u5f53\u5929\u7ed3\u675f\u65f6\u95f4\r\n}\r\nif ($altime == \"\u6628\u5929\") {\r\n\t$t = time();\r\n\t$first = date('Y-m-d H:i:s', mktime(0, 0, 0, date(\"m\"), date(\"d\", $t) - 1, date(\"Y\", $t)));\r\n\t$last = date('Y-m-d H:i:s', mktime(23, 59, 59, date(\"m\"), date(\"d\", $t) - 1, date(\"Y\", $t)));\r\n}\r\nif ($altime == \"\u672c\u5468\") {\r\n\t$timestamp = time();\r\n\t$first = date('Y-m-d H:i:s', strtotime(\"this week Monday\", $timestamp));\r\n\t$last = date('Y-m-d H:i:s', (strtotime(date('Y-m-d H:i:s', strtotime(\"this week Sunday\", $timestamp))) + 24 * 3600 - 1));\r\n}\r\nif ($altime == \"\u4e0a\u5468\") {\r\n\t$timestamp = time();\r\n\t$first = date('Y-m-d', strtotime(\"last week Monday\", $timestamp));\r\n\t$last = date('Y-m-d H:i:s', (strtotime(date('Y-m-d', strtotime(\"last week Sunday\", $timestamp))) + 24 * 3600 - 1));\r\n}\r\nif ($altime == \"\u672c\u6708\") {\r\n\t$date = date(\"Y-m-d\");\r\n\t\/\/ \u672c\u6708\u7b2c\u4e00\u5929\r\n\t$first = date('Y-m-01 0:0:0', strtotime($date));\r\n\t\/\/ \u672c\u6708\u6700\u540e\u4e00\u5929\r\n\t$last = date('Y-m-d 23:59:59', strtotime(\"$first +1 month -1 day\"));\r\n}\r\nif ($altime == \"\u4e0a\u6708\") {\r\n\t$first = date('Y-m-d H:i:s', mktime(0, 0, 0, date('m') - 1, 1, date('Y')));\r\n\t$last = date('Y-m-d H:i:s', mktime(23, 59, 59, date('m') - 1, date('t', $first), date('Y')));\r\n}\r\nif ($altime == \"\u672c\u5b63\u5ea6\") {\r\n\t$season = ceil(date('n') \/ 3);\r\n\t$first = date('Y-m-d H:i:s', mktime(0, 0, 0, ($season - 1) * 3 + 1, 1, date('Y')));\r\n\t$last = date('Y-m-d H:i:s', mktime(0, 0, 0, $season * 3, 1, date('Y')));\r\n}\r\nif($altime == \"\u4e0a\u5b63\u5ea6\") {\r\n\t$season = ceil(date('n') \/ 3);\r\n\t$first = date('Y-m-d H:i:s', mktime(0, 0, 0, ($season - 2) * 3 + 1, 1, date('Y')));\r\n\t$last = date('Y-m-d H:i:s', mktime(23, 59, 59, ($season - 1) * 3, 1, date('Y')));\r\n}\r\nif ($altime == \"\u672c\u5e74\") {\r\n\t$first = date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, date('Y')));\r\n\t$last = date('Y-m-d H:i:s', mktime(23, 59, 59, 12, 31, date('Y')));\r\n}\r\nif ($altime == \"\u4e0a\u5e74\") {\r\n\t$year = date('Y') - 1;\r\n\t$first = date('Y-m-d H:i:s', mktime(0, 0, 0, 1, 1, $year));\r\n\t$last = date('Y-m-d H:i:s', mktime(23, 59, 59, 12, 31, $year));\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>if ($altime == &#8220;\u4eca\u65e5&#8221;) { $t = time(); $first = date(&#8216;Y-m- [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[35],"class_list":["post-351","post","type-post","status-publish","format-standard","hentry","category-php","tag-35"],"_links":{"self":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts\/351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=351"}],"version-history":[{"count":0,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts\/351\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}