Home > Article > Backend Development > PHP Get the start and end dates of each week of the year_PHP Tutorial
As for the examples of PHP acquisition date, Agni Academy has mentioned many examples for you, and you can use Agni Search to retrieve them. When browsing some technical blogs today, I found that the blog of City Without Tears has updated a blog post "Using PHP to Get the Start and End Dates of Each Week of the Year", which is specially reproduced for everyone to learn from. The following is the original content:
In a recent project, I need to create a function to submit weekly reports. I need to know the start and end dates of specified weeks in order to handle other business. The following is a piece of code that uses PHP to get the start date and end date of each week of the year to share with you.
The following is a code that uses PHP to get the start date and end date of each week of the year.
Copy to ClipboardQuoted content: [www.bkjia.com] function get_week($year) {The function get_week() gets the week number of the first and last days of the year by passing in the parameter $year, calculates the date of the first week, and obtains the dates of the first and last days of each week through a loop. The final return is an array.
If you want to get the start date and end date of a specified week, such as the start date and end date of week 18 in 2011, the code is as follows:
Copy to ClipboardQuoted content: [www.bkjia.com] $weeks = get_week(2011);Final output result:
1. Week 18 start date: 2011.05.02
2. Week 18 end date: 2011.05.08