php get day from date
$timestamp = strtotime('2009-10-22');
$day = date('D', $timestamp);
var_dump($day);
php get day from date
$timestamp = strtotime('2009-10-22');
$day = date('D', $timestamp);
var_dump($day);
how to find this day is holiday in php day
//function that checks if a holiday lands on saturday/sunday and so we can move them to a friday/monday respectively
private function getObservedDate($holidayDate){
$dayofweek = date("w", strtotime($holidayDate));
if ($dayofweek == 6) $holidayDate = date('m/d/Y', strtotime("$holidayDate - 1 days")); //saturday moves to friday
else if ($dayofweek == 0) $holidayDate = date('m/d/Y', strtotime("$holidayDate + 1 days")); //sunday moves monday
return $holidayDate;
}
//function that calculates the holidays for any given year
private function getFederalHolidaysForYear($year){
$NY = $this->getObservedDate( date('m/d/Y', strtotime("1/1/$year")) ); //new years day
$MLK = $this->getObservedDate( date('m/d/Y', strtotime("third monday of january $year")) ); //martin luther king day
$PD = $this->getObservedDate( date('m/d/Y', strtotime("third monday of february $year")) ); ; //presidents day
$MDay = $this->getObservedDate( date('m/d/Y', strtotime("last monday of May $year")) ); //memorial day
$IDay = $this->getObservedDate( date('m/d/Y', strtotime("7/4/$year")) ); // independence day
$LD = $this->getObservedDate( date('m/d/Y', strtotime("first monday of september $year")) ); //labor day
$VD = $this->getObservedDate( date('m/d/Y', strtotime("11/11/$year")) ); //veterans day
$ColD =$this->getObservedDate( date('m/d/Y', strtotime("second monday of october $year")) ); //columbus day
$TG = $this->getObservedDate( date('m/d/Y', strtotime("last thursday of november $year")) ); // thanksgiving
$CD = $this->getObservedDate( date('m/d/Y', strtotime("12/25/$year")) ); //christmas day
$nonWorkingDays = array();
array_push($nonWorkingDays, $NY, $MLK, $PD, $MDay, $IDay, $LD, $ColD, $VD, $TG, $CD);
return $nonWorkingDays;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us