PHP obtains the year, month, and day of the current week based on the year, month, and day of the current day.

Source: Internet
Author: User
PHP obtains the year, month, and day of the current week based on the year, month, and day of the current day.

  1. // Obtain the end date of the latest week corresponding to the year, month, and day.
  2. Function GetClearWeek (){
  3. $ Year_month_day_over = array ();
  4. $ Year = date ('Y'); // year with four digits
  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'); // Day of Week 1-7
  8. $ Day_of_year = date ('Z') + 1; // The Day of January 1, 366
  9. $ Days_of_month = date ('t'); // The number of days of the current month
  10. $ Day_should_over = $ day_of_month-$ day_of_week + 7;
  11. If ($ day_should_over> $ days_of_month ){
  12. $ Month_over = $ month + 1;
  13. If ($ month_over> 12 ){
  14. $ Year_month_day_over = array (
  15. 'Year _ over' => $ year + 1, 'Month _ over' => 1, 'day _ over' => $ day_should_over-$ days_of_month,
  16. );
  17. } Else {
  18. $ Year_month_day_over = array (
  19. 'Year _ over' => $ year, 'Month _ over' => $ month + 1, 'day _ over' => $ day_should_over-$ days_of_month,
  20. );
  21. }
  22. } Else {
  23. $ Year_month_day_over = array (
  24. 'Year _ over' => $ year, 'Month _ over' => $ month, 'day _ over' => $ day_should_over,
  25. );
  26. }
  27. Return $ year_month_day_over;
  28. }


PHP

Related Article

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.