PHP returns an odd and even number of php statements every Saturday.

Source: Internet
Author: User
PHP returns an odd and even number of php statements every Saturday.

Requirement description: determines whether a week is a double week or a single week based on the Saturday date. that is, if the date on Saturday is a singular number, this week is a single break. if it is a double number, it is a double break. We didn't take into account the different days of each month before, which leads to inaccurate judgment. after modification, it is now accurate.

For example, PHP obtains the code for php to judge the odd and even numbers every Saturday.

  1. $ Ts = date ('t'); // get the total number of days of the month
  2. $ Rq = date ('D'); // get the date of today
  3. $ Xq = date ('w'); // Obtain the day of the week. 1-6 indicates the day of the week. 1-6 indicates the day of the week. 0 indicates the day of the week.
  4. // Calculate the number of days from Saturday
  5. If ($ xq = 6 ){
  6. $ Date1 = 0;
  7. } Else if ($ xq = 0 ){
  8. $ Date1 =-1;
  9. } Else {
  10. $ Date1 = 6-$ xq ;}
  11. // Use the current date plus the number of days from Saturday
  12. $ Rq = $ rq + $ date1;
  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 = $ date1;
  20. } Bbs.it-home.org
  21. // Obtain the date on Saturday after calculation, and then judge the odd and even numbers of dates.
  22. $ A = $ rq;
  23. $ A = $ a % 2;
  24. If ($ a = 0 ){
  25. Echo 'Saturday: '. $ rq.', this week is a two-week ';
  26. }
  27. Else {
  28. Echo 'Saturday is: '. $ rq.', this week is a week ';
  29. }
  30. ?>

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.