PHP Gets the odd even number of PHP judgements per week 6th

Source: Internet
Author: User

Requirements Description: According to the date of every Saturday to determine whether it is bi-weekly, weekly, that is, if the date of Saturday is the singular, then this week is a single break, if it is even, that is double Hugh. Before taking into account the difference in the number of days per month, the judgment is not very accurate and has been modified, and is now accurate.

Example, PHP gets the odd even implementation code of PHP judgment for the 6th period of each week.

    1. $ts =date (' t ');//Get total number of days of the month
    2. $rq =date (' d ');//Get today's date
    3. $xq =date (' W ');//Get today's week, 1-6 for week 1-6, 0 for Sunday
    4. Calculate the number of days from Saturday
    5. if ($xq ==6) {
    6. $date 1 = 0;
    7. }else if ($xq ==0) {
    8. $date 1 =-1;
    9. }else{
    10. $date 1= 6-$xq;}
    11. Use the current date plus the number of days from Saturday
    12. $RQ = $rq + $date 1;
    13. Compare with the total number of days of the month
    14. if ($rq <= $ts) {
    15. $RQ = $RQ;
    16. }else if ($rq > $ts) {
    17. $RQ = $rq-$ts;
    18. }else{
    19. $RQ = $date 1;
    20. } bbs.it-home.org
    21. The date of the Saturday is calculated, and then the date is judged by an odd even number.
    22. $a = $RQ;
    23. $a = $a% 2;
    24. if ($a ==0) {
    25. Echo ' This Saturday is: '. $rq. ', this week is two weeks ';
    26. }
    27. else{
    28. Echo ' This Saturday is: '. $rq. ', this week is one week ';
    29. }
    30. ?>
Copy Code
  • 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.