function niceTime($timeLeft, $count = 10) { @($oldTz = date_default_timezone_get()); date_default_timezone_set("UTC"); $tl = array(); $days = (int) ($timeLeft / (24 * 60 * 60)); $hours = trimZeros(strftime("%H", $timeLeft)); $mins = trimZeros(strftime("%M", $timeLeft)); $secs = trimZeros(strftime("%S", $timeLeft)); date_default_timezone_set($oldTz); if ($days > 0) { $tl[] = $days . " day" . ($days == 1 ? "" : "s"); } if ($hours > 0) { $tl[] = $hours . " hour" . ($hours == 1 ? "" : "s"); } if ($mins > 0) { $tl[] = $mins . " minute" . ($mins == 1 ? "" : "s"); } if ($secs > 0) { $tl[] = $secs . " second" . ($secs == 1 ? "" : "s"); } if (empty($tl[0])) { return ""; } $rem = $tl[0]; for ($i = 1; $i < count($tl) && $i < $count; $i++) { $rem .= ", " . $tl[$i]; } return $rem; }
function orders_time($timeLeft) { @($oldTz = date_default_timezone_get()); date_default_timezone_set("UTC"); $days = (int) ($timeLeft / (24 * 60 * 60)); $hours = trimZeros(strftime("%H", $timeLeft)); $mins = trimZeros(strftime("%M", $timeLeft)); $secs = trimZeros(strftime("%S", $timeLeft)); $tl = ""; if ($days > 0) { $tl .= $days . "D "; } if ($hours > 0) { $tl .= $hours . "H "; } if ($mins > 0) { $tl .= $mins . "M "; } if ($secs > 0) { $tl .= $secs . "S"; } date_default_timezone_set($oldTz); return $tl; }