PHP Gets an example of the start date and end date of the first few weeks of the year

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.