So, I have a script that performs several checks 32, 48, and 72 hours ago. Basically I check my database for records that are not older than x hours.
Now it works like this:
$date = date('Ymd H:i:s',strtotime('-32 hours')); $q = "SELECT * FROM `table` WHERE `date` <= '".$date."'";
Now I want this to exclude the weekend. I know that you can use weekdays inside strtotime to get this effect, however this does not work for several hours.
Within 48 hours, this is easy because I can simply do the following:
echo date('Ymd H:i:s', strtotime(date("Ymd H:i:s"). " -2 weekdays ". date('H:i:s')));
Within 72 hours, it is also easy, because it is 3 days. However, 32 hours creates a problem because it is ± 1.3 days.
In conclusion, how do I get datetime 32 hours ago excluding weekends.
Kokos source share