Detect leap year

Detect leap year for gregorian and shamsi date.

function gLeapYear($year)
{
    if (($year % 4 == 0) and (($year % 100 != 0) or ($year % 400 == 0)))
        return true;
    else
        return false;
}
 
function sLeapYear($year)
{
    $ary = array(1, 5, 9, 13, 17, 22, 26, 30);
    $b = $year % 33;
    if (in_array($b, $ary))
        return true;
    return false;
}
 
echo sLeapYear(1392).' ';
echo gLeapYear(2013);

Tags

No tag here.

Recommended pages

Parse a string into separate words...

Parse a string into separate words (array output). function parser($str, $char = ' ') { $str = trim($str); $str = $str . $char; $len = strlen($str); $words = array(); $w = '...

Download a file from web to local...

Use this function to download a file from web to local machine. function WgetFile( $URL, $dir ) { $nomefile = $dir . "/" . basename( $URL ); if ( copy( $URL, $nomefile ) ) { retu...

Gregorian to Persian Date Convertor...

Gregorian to Persian Date Convertor....

UTF8 string length counter...

The best way to determine the character count of a UTF8 string. function strlen_utf8( $str ) { return mb_strlen( $str, 'UTF-8' ); }   //or... function strlen_utf8( $str ) { $c = 0;...