PHP gets the code for last week, this week, last month, this month, this quarter, and last quarter

Source: Internet
Author: User
Tags echo date
  1. echo Date ("Ymd", Strtotime ("Now"), "\\n";
  2. echo Date ("Ymd", Strtotime ("1 week Monday")), "\\n";
  3. echo Date ("Ymd", Strtotime ("1 week Sunday")), "\\n";
  4. echo Date ("Ymd", Strtotime ("+0 Week Monday")), "\\n";
  5. echo Date ("Ymd", Strtotime ("+0 Week Sunday")), "\\n";
  6. echo "********* months:";
  7. echo Date (' n ');
  8. echo "********* Week of the week:";
  9. Echo Date ("W");
  10. echo "********* Days of the Month:";
  11. echo Date ("T");
  12. echo "*********";
  13. Echo '
    Last week start time:
    ';
  14. echo Date ("Y-m-d h:i:s", mktime (0, 0, 0,date ("M"), Date ("D")-date ("W") +1-7,date ("Y")), "\\n";
  15. echo Date ("Y-m-d h:i:s", Mktime (23,59,59,date ("M"), Date ("D")-date ("W") +7-7,date ("Y")), "\\n";
  16. Echo '
    Starting time of the week:
    ';
  17. echo Date ("Y-m-d h:i:s", mktime (0, 0, 0,date ("M"), Date ("D")-date ("W") +1,date ("Y")), "\\n";
  18. echo Date ("Y-m-d h:i:s", Mktime (23,59,59,date ("M"), Date ("D")-date ("W") +7,date ("Y")), "\\n";
  19. Echo '
    Last month start time:
    ';
  20. echo Date ("Y-m-d h:i:s", mktime (0, 0, 0,date ("M") -1,1,date ("Y")), "\\n";
  21. echo Date ("Y-m-d h:i:s", Mktime (23,59,59,date ("M"), 0,date ("Y")), "\\n";
  22. Echo '
    Starting time of the month:
    ';
  23. echo Date ("Y-m-d h:i:s", mktime (0, 0, 0,date ("M"), 1,date ("Y")), "\\n";
  24. echo Date ("Y-m-d h:i:s", Mktime (23,59,59,date ("M"), Date ("T"), Date ("Y")), "\\n";
  25. $season = Ceil ((date (' n '))/3);//The month of the first quarter
  26. Echo '
    Starting time of the quarter:
    ';
  27. echo Date (' y-m-d h:i:s ', mktime (0, 0, 0, $season *3-3+1,1,date (' Y ')), "\\n";
  28. echo Date (' y-m-d h:i:s ', Mktime (23,59,59, $season *3,date (' t ', mktime (0, 0, 0, $season *3,1,date ("y"))), date (' Y ')), "\\n ";
  29. $season = Ceil ((date (' n '))/3) -1;//quarter of last quarter
  30. Echo '
    Last quarter start time:
    ';
  31. echo Date (' y-m-d h:i:s ', mktime (0, 0, 0, $season *3-3+1,1,date (' Y ')), "\\n";
  32. echo Date (' y-m-d h:i:s ', Mktime (23,59,59, $season *3,date (' t ', mktime (0, 0, 0, $season *3,1,date ("y"))), date (' Y ')), "\\n ";
  33. ?>
Copy Code
Php
  • 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.