I want to print out different information as shown in my code for each different date(day) of the year, but I seem not to get the answer. Every other day of the week works fine, but the weekends(Sat and Sun) has been a headache. I want to print the correct date on weekends. For example, let’s take this week and next week weekends, I should have the following prints: Happy Weekend, today is Saturday 2019-02-09. And on the next day which is a Sunday, I should print out: Happy Weekend, today is Sunday 2019-02-10. Also next week weekends should give 2019-02-16 and 2019-02-17 respectively on different days of the weekend, but this is not happening. See my code:
$date = new DateTime('');
$datei = $date->format('Y-m-d');
$newYear = new DateTime('');
$newYear_date = $newYear->format('2019-01-01');
$ValentineS = new DateTime('');
$valentineS_date = $ValentineS->format('2019-02-14');
$WomenDay = new DateTime('');
$WomenDay_date = $WomenDay->format('2019-03-08');
/* ...other days not shown for brevity..*/
/*...move to the weekends....*/
$sat_begin = new DateTime('2019-01-21');
$sat_end = new DateTime('2019-12-30');
$sat_end = $sat_end->modify('+4 day');
$sat_interval = new DateInterval('P1D');
$sat_daterange = new DatePeriod($sat_begin, $sat_interval, $sat_end);
$sun_begin = new DateTime('2019-01-22');
$sun_end = new DateTime('2019-12-31');
$sun_end = $sun_end->modify('+4 day');
$sun_interval = new DateInterval('P1D');
$sun_daterange = new DatePeriod($sun_begin, $sun_interval, $sun_end);
foreach ($sat_daterange as $sat_date){
$saturday = date('w', strtotime($sat_date->format('Y-m-d')));
if ($saturday == 6 && $datei == $sat_date) {
}
}foreach ($sun_daterange as $sun_date) {
$sunday = date('w', strtotime($sun_date->format('Y-m-d')));
if ($sunday == 0 && $datei == $sun_date) {
}
}
switch ('Y-m-d') {
case '2019-01-01':
echo 'HAPPY NEW YEAR today is Tuesday 2019-01-01. A Public Holiday';
break;
case '2019-02-14':
echo "HAPPY VALENTINE'S DAY , today is Thursday 2019-02-14 an observed
day, but NOT A PUBLIC HOLIDAY ";
break;
case '2019-03-08':
echo "HAPPY WOMEN'S DAY , today is Friday 2019-03-08 an observed day to
recognize women, but NOT A PUBLIC HOLIDAY ";
break;
case $sat_date->format('Y-m-d'):
echo 'HAPPY WEEKEND, today is '.'<b>'.'Saturday '.$sat_date->format("Y-m-d").'</b>'.'<br>' ;
break;
case $sun_date->format("Y-m-d"):
echo 'HAPPY WEEKEND, today is '.'<b>'.'Sunday '.$sun_date->format("Y-m-d").'</b>'.'<br>' ;
break;
default:
echo "TODAY IS A WORKDAY, have a good day!".'<br>';
break;
```