I recently found Alex Ilhan's tutorial for making a countdown timer that can be embedded as a .gif file onto a web page or into an email. I have used this script with a different font and background and the results are beautiful! My question, however, is can a line of script be added to make the timer's font color change when there is only a specific amount of time remaining? I set the countdown as a weekly countdown that that resets automatically, and I was wondering if their was a way to make the font color turn red when it reached that final hour before reset. I know it should be possible, but I'm not sure how to approach it. I have pasted in the code below for examination.

Thanks!

<?php

    //Leave all this stuff as it is
    date_default_timezone_set('America/Chicago');
    include 'GIFEncoder.class.php';
    include 'php52-fix.php';
    $time = $_GET['time'];
    $future_date = new DateTime(date('r',strtotime($time)));
    $time_now = time();
    $now = new DateTime(date('r', $time_now));
    $frames = array();  
    $delays = array();


    // Your image link
    $image = imagecreatefrompng('images/countdown.png');

    $delay = 100;// milliseconds

    $font = array(
        'size'=>38, // Font size, in pts usually.
        'angle'=>0, // Angle of the text
        'x-offset'=>30, // The larger the number the further the distance from the left hand side, 0 to align to the left.
        'y-offset'=>65, // The vertical alignment, trial and error between 20 and 60.
        'file'=>'letter.ttf', // Font path
        'color'=>imagecolorallocate($image, 55, 160, 130), // RGB Colour of the text
    );
    for($i = 0; $i <= 60; $i++){

        $interval = date_diff($future_date, $now);

        if($future_date < $now){
            // Open the first source image and add the text.
            $image = imagecreatefrompng('images/countdown.png');
            ;
            $text = $interval->format('00:00:00:00');
            imagettftext ($image , $font['size'] , $font['angle'] , $font['x-offset'] , $font['y-offset'] , $font['color'] , $font['file'], $text );
            ob_start();
            imagegif($image);
            $frames[]=ob_get_contents();
            $delays[]=$delay;
            $loops = 1;
            ob_end_clean();
            break;
        } else {
            // Open the first source image and add the text.
            $image = imagecreatefrompng('images/countdown.png');
            ;
            $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);
            $frames[]=ob_get_contents();
            $delays[]=$delay;
            $loops = 0;
            ob_end_clean();
        }

        $now->modify('+1 second');
    }

    //expire this image instantly
    header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
    header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
    header( 'Cache-Control: no-store, no-cache, must-revalidate' );
    header( 'Cache-Control: post-check=0, pre-check=0', false );
    header( 'Pragma: no-cache' );
    $gif = new AnimatedGif($frames,$delays,$loops);
    $gif->display();
    ```