Get the last day of a month or the number of days in a month

WBOY
Release: 2016-07-25 08:46:11
Original
756 people have browsed it
  1. //Get the last day of a month or the number of days in a month
  2. function getMonthLastDay ( $month, $year )
  3. {
  4. switch ( $month )
  5. {
  6. case 4 :
  7. case 6 :
  8. case 9 :
  9. case 11 :
  10. $days = 30;
  11. break;
  12. case 2 :
  13. if ( $year % 4 == 0 )
  14. {
  15. if ( $year % 100 == 0 )
  16. {
  17. $days = $year % 400 == 0 ? 29 : 28;
  18. }
  19. else
  20. {
  21. $days = 29;
  22. }
  23. }
  24. else
  25. {
  26. $days = 28;
  27. }
  28. break;
  29. default :
  30. $days = 31 ;
  31. break;
  32. }
  33. return $days;
  34. }
Copy code



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!