From 105bce2b6561bf04bc05f80fd6a08a7ab417b2d9 Mon Sep 17 00:00:00 2001 From: Sergiy Posternak Date: Fri, 15 Jun 2018 22:05:10 +0300 Subject: [PATCH] change date format Add zero at the beginning only if number of days is less then 10. --- gif.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gif.php b/gif.php index b7d150d..40b51ba 100755 --- a/gif.php +++ b/gif.php @@ -46,7 +46,11 @@ // Open the first source image and add the text. $image = imagecreatefrompng('images/countdown.png'); ; - $text = $interval->format('0%a %H %I %S'); + if ($interval->days > 9) { + $text = $interval->format('%a %H %I %S'); + } else { + $text = $interval->format('0%a %H %I %S'); + } imagettftext ($image , $font['size'] , $font['angle'] , $font['x-offset'] , $font['y-offset'] , $font['color'] , $font['file'], $text ); ob_start(); imagegif($image);