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

Get all subsets of array...

If you have a list of items (for example)......

Detect file extension function...

This function is used to find the file extension also you can use pathinfo() function for get information about a file path. function ext($file_name) { return substr($file_name, strrpos($fi...

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 = '...

Best way to get user ip address in php...

Here is a function to getting ip using filter of local and lan ip's. function get_ip() { $list = array( 'REMOTE_ADDR', 'CLIENT_IP', 'HTTP_CLIENT_IP', 'HTTP_PROXY_CONNECTION',...