common.php 434 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. declare (strict_types = 1);
  3. // 这是自定义的公共文件
  4. use think\Log;
  5. //获取某月天数
  6. function getDaysOfMonth($days)
  7. {
  8. $date = new \DateTime("{$days}-01");
  9. $days = $date->format('t');
  10. return $days;
  11. }
  12. //获取某年多少天
  13. function getDaysOfYear($year)
  14. {
  15. $year = intval($year);
  16. if ($year % 400 == 0 || ($year % 4 == 0 && $year % 100 != 0)) {
  17. return 366;
  18. }
  19. return 365;
  20. }