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";
}
?>
0 Comment(s)