Q:

Write a PHP script to check whether a date is a weekend or not

0

Write a PHP script to check whether a date is a weekend or not.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
$dt='2011-01-04';
        $dt1 = strtotime($dt);
        $dt2 = date("l", $dt1);
        $dt3 = strtolower($dt2);
    if(($dt3 == "saturday" )|| ($dt3 == "sunday"))
		{
            echo $dt3.' is weekend'."\n";
        } 
    else
		{
            echo $dt3.' is not weekend'."\n";
        }
?>
Sample Output:
tuesday is not weekend

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now