Wednesday, 1 April 2015

How to find given date is Sunday or not ?

<?php
function findleave($systemtardt)
{
    $comity_dt=date('Y-m-d',strtotime($systemtardt));

    $inputDateArray = explode('-', $comity_dt);
    if(date('N', mktime (0, 0 , 0, $inputDateArray[1], $inputDateArray[2], $inputDateArray[0])) == 7)
    {
        return "1";  //sunday
    }
    else
    {
        return "0";
    }
                   
}

if(isset($_REQUEST['findleave']))
{
    echo findleave($_REQUEST['dp']);
}
?>
<form name="test" method="post">
<input type="text" name="dp" />
<input type="submit" name="findleave" />
</form>

No comments:

Post a Comment