The following small series for you to share a PHP to get the first few weeks of the start date and the end date of the instance, has a good reference value, I hope to be helpful to everyone. Let's take a look at it with a little knitting.
The examples are as follows:
/** * Gets the start date and end date of the first few weeks of the year * @param int $year * @param int $week the first week; */Public Function Weekday ($year, $week =1) {$year _start = mktime (0,0,0,1,1, $year); $year _end = Mktime (0,0,0,12,31, $year); Determines if the first day is the start of the first week if (intval (' W ', $year _start) ===1) {$start = $year _start;//The first day as the start of the first week}else{$week + +; $start = Strtotime (' +1 Monday ', $year _start);//start of the first Monday}//start of week if ($week ===1) {$weekday [' start '] = $sta Rt }else{$weekday [' start '] = strtotime (' + '). ( $week -0). ' Monday ', $start); }//End time of the week $weekday [' end '] = Strtotime (' +1 Sunday ', $weekday [' Start ']); if (date (' Y ', $weekday [' End '])! = $year) {$weekday [' end '] = $year _end; } return $weekday; }/** * Calculates the number of weeks of the year, starting from Monday, if the last day of the week after Thursday (including Thursday), is not counted as the last week of the year * If the first day is a full week before Thursday (including Thursday), it does not count towards the first week of the year * @param int $ye AR * return int */Public Function Week ($year) {$year _start = mktime (0,0,0,1,1, $year); $year _end = Mktime (0,0,0,12,31, $year); if (Intval (date (' W ', $year _end)) ===1) {RetuRN Date (' W ', Strtotime (' Last week ', $year _end)); }else{return date (' W ', $year _end); } }
The above this PHP get the first few weeks of the year start date and end date of the example is small part to share all the content, I hope to give you a reference, but also hope that we support PHP Chinese network.
Articles you may be interested in:
PHP interface Multi-Inheritance and tarits method to realize multi-inheritance effect _php tips
A detailed description of the cache () usage of THINKPHP5 Framework database coherent operation
thinkPHP3.2 How to implement pagination custom styles