Is it possible to find number of days between Friday and Tuesday?

I’m working on a project that requires to calculate the number of days between a specific range of days like (between Friday and Tuesday), how can I get this dynamically?

Yes, it’s quite possible with PHP’s DateTime class:

$datetime1 = new DateTime('Tuesday');
$datetime2 = new DateTime('Friday');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%a days');    

Which dates to pass is up to you. Just note that you can use “next Friday” or “last Tuesday” as well.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.