Question:
How do I know if the current year is a leap year in PHP?
Answer:
Another way is to use the date
function with the L
parameter which returns 1
if it is in a leap year, 0
otherwise.
Example for current year:
echo date('L');
For a specific year:
$ano = 2007;
$bissexto= date('L', mktime(0, 0, 0, 1, 1, $ano));
echo $ano . ' ' . ($bissexto? 'é' : 'não é') . ' um ano bissexto.';
See working on ideone .