I need to calculate the remaining time (days / hours) before a specific date / time.
However, I am not using a static date.
Imagine that I have an event at 17:00 on every Sunday . I need to display the remaining time until the next event, that is, the coming Sunday at 17:00.
I found the following code in the answer. It works for a static date / time, but obviously this is not what I am looking for.
$now = new DateTime();
$future_date = new DateTime('2011-05-11 12:00:00');
$interval = $future_date->diff($now);
echo $interval->format("%d days, %h hours, %i minutes, %s seconds");
Thank you for your time.
source
share