So this was my waste of time leap year calculating function..
<?php
$year = date('Y') ;
if ( $year %400 == 0 ) { $isleap = 'yes' ; }
elseif ( $year %100 == 0 ) { $isleap = 'no' ; }
elseif ( $year %4 == 0 ) { $isleap = 'yes' ; }
else {$isleap='no';}
if ( $isleap == 'yes')
{echo $year." is a leap year";}
else
{echo $year." is not a leap year";}
?>
The smart way to do it though is just with date('L'), this php function returns 1 if it is a leap year and 0 if it is not...much simpler...
<?php
$year=date('Y');
$isleap = date('L') ;
if ( $isleap == '1')
{echo $year." is a leap year";}
else
{echo $year." is not a leap year";}
?>
No comments:
Post a Comment