Heim  >  Artikel  >  Backend-Entwicklung  >  获取某个月的最后一天或某个月的天数

获取某个月的最后一天或某个月的天数

WBOY
WBOYOriginal
2016-07-25 08:46:11757Durchsuche
  1. //获取某个月的最后一天或某个月的天数
  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. }
复制代码



Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn