PHP obtains the year, month, and day of the current week based on the year, month, and day of the current day.
- // Obtain the end date of the latest week corresponding to the year, month, and day.
- Function GetClearWeek (){
- $ Year_month_day_over = array ();
- $ Year = date ('Y'); // year with four digits
- $ Month = date ('N'); // 1 to 12
- $ Day_of_month = date ('J'); // The Day of the month from 1 to 31
- $ Day_of_week = date ('N'); // Day of Week 1-7
- $ Day_of_year = date ('Z') + 1; // The Day of January 1, 366
- $ Days_of_month = date ('t'); // The number of days of the current month
-
- $ Day_should_over = $ day_of_month-$ day_of_week + 7;
- If ($ day_should_over> $ days_of_month ){
- $ Month_over = $ month + 1;
- If ($ month_over> 12 ){
- $ Year_month_day_over = array (
- 'Year _ over' => $ year + 1, 'Month _ over' => 1, 'day _ over' => $ day_should_over-$ days_of_month,
- );
- } Else {
- $ Year_month_day_over = array (
- 'Year _ over' => $ year, 'Month _ over' => $ month + 1, 'day _ over' => $ day_should_over-$ days_of_month,
- );
- }
- } Else {
- $ Year_month_day_over = array (
- 'Year _ over' => $ year, 'Month _ over' => $ month, 'day _ over' => $ day_should_over,
- );
- }
- Return $ year_month_day_over;
- }
|
PHP