Need to modify PHP code for date countdown (want to show nothing when count reaches 0)
I'm using the following code to show a text visual countdown to a specific date, broken down into months, weeks, days. Works great. However, when the countdown reaches the actual event date and then exceeds the event date it still shows the absolute difference. I want the code instead display nothing at this point (no output to screen). I would appreciate some guidance on how to modify this code to perform as explained.
$d1 = new DateTime(); // now
$d2 = new DateTime('2014-01-08'); // set the date +1 to compensate for 1-day
error in script
$diff = $d2->diff($d1);
list($y,$m,$d) = explode('-', $diff->format('%y-%m-%d'));
$months = $y*12 + $m;
$weeks = floor($d/7);
$days = $d%7;
printf('Countdown To Event - ');
if ($months) {printf('%d month%s ', $months, $months>1?'s':'');}
if ($weeks) {printf('%d week%s ', $weeks, $weeks>1?'s':'');}
if ($days) {printf('%d day%s ', $days, $days>1?'s':'');}