Home >Backend Development >PHP Tutorial >PHP gets the year, month and day of Sunday of the current week based on the day, month and year of the current day

PHP gets the year, month and day of Sunday of the current week based on the day, month and year of the current day

WBOY
WBOYOriginal
2016-07-25 08:42:321049browse
  1. //The deadline for getting the nearest Sunday corresponding to the year, month and day may span years, months and weeks
  2. function GetClearWeek() {
  3. $year_month_day_over = array();
  4. $year = date('Y' ); //Four-digit year
  5. $month = date('n'); //1 to 12
  6. $day_of_month = date('j'); //The day of the month from 1 to 31
  7. $day_of_week = date('N'); //1-7 days of the week
  8. $day_of_year = date('z')+1; //1-366 days of the year
  9. $days_of_month = date('t' ; ; 12) {
  10. $year_month_day_over = array(
  11. 'year_over' => $year + 1,'month_over' => 1,'day_over' => $day_should_over - $days_of_month,
  12. );
  13. } else {
  14. $year_month_day_over = array(
  15. 'year_over' => $year ,'month_over' => $month + 1,'day_over' => $day_should_over - $days_of_month,
  16. );
  17. }
  18. } else {
  19. $year_month_day_over = array(
  20. 'year_over' => $year ,'month_over' => $month,'day_over' => $day_should_over,
  21. );
  22. }
  23. return $year_month_day_over;
  24. }
  25. Copy code
PHP
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn