Php get date (today, the day before yesterday, tomorrow, this week, this month, this quarter, this year)

Source: Internet
Author: User
: This article mainly introduces the php acquisition date (the day before yesterday, tomorrow, this week, this month, this quarter, and this year). If you are interested in PHP tutorials, refer to it.

  1. $ Begin_day = date ("Y-m-d 00:00:00 ");
  2. $ End_day = date ("Y-m-d 23:59:59 ");
  3. $ Last_begin = date ("Y-m-d 00:00:00", strtotime ("last days "));
  4. $ Last_end = date ("Y-m-d 23:59:59", strtotime ("last days "));
  5. $ Next_begin = date ("Y-m-d 00:00:00", strtotime ("next days "));
  6. $ Next_end = date ("Y-m-d 23:59:59", strtotime ("next days "));
  7. $ Month_times = strtotime (date ("Y-m "));
  8. $ Monthday = date ("t ");
  9. $ Month = date ("n ");
  10. $ Begin_this_week = date ("Y-m-d 00:00:00", strtotime ("last Sunday + 1 day "));
  11. $ End_this_week = date ("Y-m-d 23:59:59", strtotime ("next Sunday "));
  12. $ Begin_this_month = date ('Y-m-01 00:00:00 ');
  13. $ End_this_month = date ("Y-m-$ monthday 23:59:59", strtotime ("this month", $ month_times ));
  14. If ($ month = 1 | $ month = 2 | $ month = 3 ){
  15. $ Begin_this_quarter = date ('Y-01-01 00:00:00 ');
  16. $ End_this_quarter = date ("Y-03-31 23:59:59 ");
  17. } Elseif ($ month = 4 | $ month = 5 | $ month = 6 ){
  18. $ Begin_this_quarter = date ('Y-04-01 00:00:00 ');
  19. $ End_this_quarter = date ("Y-06-30 23:59:59 ");
  20. } Elseif ($ month = 7 | $ month = 8 | $ month = 9 ){
  21. $ Begin_this_quarter = date ('Y-07-01 00:00:00 ');
  22. $ End_this_quarter = date ("Y-09-30 23:59:59 ");
  23. } Else {
  24. $ Begin_this_quarter = date ('Y-10-01 00:00:00 ');
  25. $ End_this_quarter = date ("Y-12-31 23:59:59 ");
  26. }
  27. $ Begin_this_year = date ('Y-01-01 00:00:00 ');
  28. $ End_this_year = date ('Y-12-31 23:59:59 ');
  29. // The first quarter is the month of July 31, the second quarter is the month of July 30, the third quarter is the month of July 30, and the fourth quarter is the month of July 31
  30. Echo "today | ";
  31. Echo "the day before yesterday | ";
  32. Echo "tomorrow | ";
  33. Echo "this week | ";
  34. Echo "this month | ";
  35. Echo "this quarter | ";
  36. Echo "this year ";

The above describes the php acquisition date (that day, the day before yesterday, tomorrow, this week, this month, this quarter, this year), including the content, if you are interested in PHP tutorials.

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.