PHP Gets the date (the day before yesterday, tomorrow, this week, this month, this quarter, this year)

Source: Internet
Author: User
Tags php tutorial

  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 January 1 to March 31, the second quarter is April 1 to June 30, the third quarter is July January-September 30, and the quarter is October January-December
  30. Echo "the day |" ;
  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 (the day before yesterday, tomorrow, this week, this month, this quarter, this year), including aspects of the content, I hope to be interested in PHP tutorial friends helpful.

  • 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.