PHP implementation method to obtain the specified date is the day of the week, php day of the week
The example in this article describes how PHP can obtain the specified day of the week. We will share this with you for your reference. The details are as follows:
<? Php header ("Content-type: text/html; charset = UTF-8"); // obtain the week function get_week ($ date) {// force convert the date format $ date_str = date ('Y-m-d', strtotime ($ date )); // encapsulate it into an array $ arr = explode ("-", $ date_str); // parameter value assignment // year $ year = $ arr [0]; // month, the output is a two-digit integer with less than two digits aligned to the right. $ month = sprintf ('% 02d', $ arr [1]); // Day, the output is a two-digit integer, $ day = sprintf ('% 02d', $ arr [2]); // The default value of hour/second is 0; $ hour = $ minute = $ second = 0; // convert to timestamp $ hour = mktime ($ hour, $ minute, $ second, $ mon Th, $ day, $ year); // obtain the number of days of the week $ number_wk = date ("w", $ week ); // custom array of weeks $ weekArr = array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday "); // returns $ weekArr [$ number_wk];} // test $ date = "2016-08-20"; echo get_week ($ date); // Saturday?>