Php simple calendar implementation code (events can be bound)-php Tutorial

Source: Internet
Author: User
Php simple calendar implementation code (events can be bound)

  1. /**
  2. * Php simple calendar
  3. * Edit: bbs.it-home.org
  4. */
  5. If (empty ($ year) $ year = date ("Y"); // initialize the year
  6. If (empty ($ month) $ month = date ("n"); // initialize the month
  7. $ Wd_ar = array ("day", "one", "two", "three", "four", "five", "six"); // array of weeks
  8. $ Wd = date ("w", mktime (0, 0, 0, $ month, 1, $ year); // The first day of the month is the day of the week.
  9. // Year link
  10. $ Y_lnk1 = $ year <= 1970? $ Year = 1970: $ year-1;
  11. $ Y_lnk2 = $ year> = 2037? $ Year = 2037: $ year + 1;
  12. // Monthly link
  13. $ M_lnk1 = $ month <= 1? $ Month = 1: $ month-1;
  14. $ M_lnk2 = $ month> = 12? $ Month = 12: $ month + 1;
  15. Echo <EOT
  16. EOT;
  17. }
  18. $ Tnum = $ wd + date ("t", mktime (0, 0, 0, $ month, 1, $ year ));
  19. Print'
  20. If ($ I % 7 = 6) print"
  21. }
  22. If ($ I % 7 = 6) print"
  23. Print'
  24. For ($ I = 0; $ I <7; $ I ++ ){
  25. Print"
  26. Print"
  27. For ($ I = 0; $ I <$ tnum; $ I ++ ){
  28. $ Date = $ I + 1;
  29. If ($ I % 7 = 0) print'
  30. If ($ I % 7 <6 & $ I % 7> 0) print'
  31. "; "; '; "; "; '; ";
    <$ Year> <$ Month>
    $ Wd_ar [$ I]
    ';
  32. If ($ I >=$ wd) print $ date-$ wd;
  33. Print"
  34. ';
  35. ?>

The above is the php calendar code introduced in this section. It provides some basic calendar functions: year, month, date, and Week display.

>>> Articles you may be interested in: php calender calendar code (solving 2038 issues) php calendar code (with demo effect) php calendar code sharing simple and practical php calendar code php efficient calendar code php calendar code three good php calendar code sharing a PHP simple calendar 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.