如何在 php 中检查年份是否平分(即闰年)?
最佳答案
您可以使用 PHP 的 date()功能来做到这一点...
// L will return 1 if it is a leap year, 0 otherwise
echo date('L');
// use your own timestamp
echo date('L', strtotime('last year'));
// for specific year
$year = 1999;
$leap = date('L', mktime(0, 0, 0, 1, 1, $year));
echo $year . ' ' . ($leap ? 'is' : 'is not') . ' a leap year.';
如果这对您有用,请告诉我,干杯!
更新:添加了特定年份的示例
关于PHP - 如何检查年份是否平分(即闰年)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5680115/