PHP Calendar code sharing simple and useful PHP calendar code

Source: Internet
Author: User
  1. Header ("Content-type:text/html;charset=utf-8");
  2. ?>
  3. /**
  4. * Simple and practical PHP calendar code
  5. * edit:bbs.it-home.org
  6. */
  7. if (!emptyempty ($_get)) {
  8. $year = $_get[' year '];
  9. $month = $_get[' month ');
  10. }
  11. if (Emptyempty ($year)) {
  12. $year = Date (' Y ');
  13. }
  14. if (Emptyempty ($month)) {
  15. $month = Date (' m ');
  16. }
  17. $start _weekday = Date (' W ', Mktime (0,0,0, $month, 1, $year));
  18. echo $start _weekday;
  19. $days = date (' t ', Mktime (0,0,0, $month, 1, $year));
  20. Echo $days;
  21. $week = Array (' Sunday ', ' Monday ', ' Tuesday ', ' Wednesday ', ' Thursday ', ' Friday ', ' Saturday ');
  22. $i = 0;
  23. $k = 1;
  24. $j = 0;
  25. Echo '
  26. Echo '
  27. Echo '
  28. for ($i = 0; $i < 7; $i + +) {
  29. }
  30. Echo '
  31. for ($j = 0; $j < $start _weekday; $j + +) {
  32. }
  33. }else{
  34. }
  35. }
  36. $j + +;
  37. echo "
  38. echo "
  39. Echo '
  40. echo "
  41. echo "
  42. Echo '
  43. Echo '
  44. Echo '
  45. Echo '
  46. Echo '
  47. while ($k <= $days) {
  48. if ($k = = Date (' d ')) {
  49. Echo '
  50. Echo '
  51. if (($j + 1)% 7 = = 0) {
  52. Echo '
  53. $j + +;
  54. $k + +;
  55. }
  56. while ($j% 7 = 0) {
  57. Echo '
  58. }
  59. Echo '
  60. Echo '
  61. '; '; '; '; '; '; '; '; '; '; '; '; '; '; '; '; '; '; ';
    '. $year. ' Year ' $month. ' Month '. '
    '. $week [$i]. '
    '. $j. ''. $k. ''. $k. '
    '. $j. '
    ".' << '. '".' < '. '';
  62. Echo ';
  63. Echo '
  64. ".' >> '. '".' > '. '
    ';
  65. function LastYear ($year, $month) {
  66. $year = $year-1;
  67. Return "year= $year &month= $month";
  68. }
  69. function Lastmonth ($year, $month) {
  70. if ($month = = 1) {
  71. $year = $year-1;
  72. $month = 12;
  73. }else{
  74. $month--;
  75. }
  76. Return "year= $year &month= $month";
  77. }
  78. function Nextyear ($year, $month) {
  79. $year = $year +1;
  80. Return "year= $year &month= $month";
  81. }
  82. function Nextmonth ($year, $month) {
  83. if ($month = = 12) {
  84. $year = $year +1;
  85. $month = 1;
  86. }else {
  87. $month + +;
  88. }
  89. Return "year= $year &month= $month";
  90. }
  91. ?>
Copy Code

>>> you may be interested in the article: PHP Calender Calendar code (solve 2038 problems) PHP Calendar code (with demo effect) PHP Calendar code PHP Implementation of efficient calendar code PHP calendar code Three good PHP calendar code to share a sample PHP simple calendar code PHP simple Calendar Implementation code (bindable events)

  • Related Article

    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.