This time I will process the data that appears on the page with special conditions, where when today is Saturday or Sunday, the date will display the previous date, namely Friday.
Stages:
- Today's date, time form and day number (
w
) - Giving the day deduction parameter (
$minus
) - Update the date to be displayed (
$t
)
$today= date('Y-m-d'); // bisa diganti dengan GETtanggal $time = strtotime($today); $day_num = date('w', $time); if ($day_num == '0') { $minus = '-2 day'; } elseif ($day_num == '6') { $minus = '-1 day'; } else { $minus = '0 day'; } $t = strtotime($today . $minus); $t = date('Y-m-d', $t);
or
// case date adalah hari ini $day_num = date('w'); if ($day_num == '0') { $minus = '-2 day'; } elseif ($day_num == '6') { $minus = '-1 day'; } else { $minus = '0 day'; } $t = date('Y-m-d', strtotime($minus));
DONE
Top comments (0)