Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to check if a given date is Sunday by PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 6.41k
    Comment on it

    Hello Reader's if you are looking for making the function which detect if a given date is weekend or not then this code will help you. This is a PHP function which will use the date as a input param and will print if its weekend or not. So the code for the function will go like this:-

    <?php
    $givendate='2011-01-01';
            $MyGivenDateIn = strtotime($date);
            $ConverDate = date("l", $MyGivenDateIn);
            $ConverDateTomatch = strtolower($ConverDate);
            echo $ConverDateTomatch;
            if(($ConverDateTomatch == "saturday" )|| ($ConverDateTomatch == "sunday")){
                echo "This is a weekend date";
            } else {
                echo "This is no weekend date";
            }
    ?>
    

    Output:

    This is a weekend date
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: