I am trying to add some php which show the time left for a prodcut on my site, a little bit like an auction. It all displays well however when the time gets lower it shows 0d 34h 12m which means 0 days, 34 hours and 12 minutes, i was wondering if there was a way to get rid of the 0d bit if there are no days left a bit like this 34h 12m, it just makes it look better, the same for when there is no hours left and just minutes.
Here is the code that calculates the time left
$date = date('m/d/Y h:i:s', time());
$date3 = new DateTime($date);
$date4 = new DateTime($time_ending);
$interval_date = $date3->diff($date4);
$time_left = $interval_date->d."d ". $interval_date->h."h ". $interval_date->i."m ";
Is there anyway i can do this?
Thanks for any help
Yes, the shortest way would be
Briefly explained
(cond) ? (stmA) : (stmB)equals
if(cond){ stmA } else{ stmB }