Reputation: 3
I have this:
$time = new DateTime('today 6 PM');
$now = new DateTime('now');
// check if current time is past 6 PM
if ($now > $time) {
$time = new DateTime('Next Saturday 6 PM');
}
$diff = $time->diff($now);
echo $diff->format("%h hours %i minutes remaining");
and want to add to the hours the days until the next Saturday, and that to every Saturday, so If we reach one it should automaticlly start itfrom beginning
Upvotes: 0
Views: 58
Reputation: 3814
You need to get each days, hours, and minutes separately:
$diff = $time->diff($now);
$days = $diff->format("%a");
$hours = $diff->format("%h");
$minutes = $diff->format("%i");
$total_hours = $days * 24 + $hours; //figure out the total hours
echo "$total_hours hours $minutes minutes remaining";
Upvotes: 0
Reputation: 7265
$plusSix = date('Y-m-d' , strtotime('+6 hours' , time())); // to add 6 hours
to check the day I think:
$dayNumber = date('w' , strtotime('2012-01-01'));
Upvotes: 1