Article written by

33 Responses

Page 1 of 1
  1. Chandni
    Chandni at | | Reply


    Thanks for sharing the code, we would want to use this code but we are facing the issue that after 60 frames the count down behaves weird. Even in the demo above, we witnessed the same. Could you please help us with it, or at-least help us understand the working as to what happens after 60 frames have passed. How are the new frames generated?

  2. amol
    amol at | | Reply

    will it possible to put this gif image on FB

  3. daniel gonzalez
    daniel gonzalez at | | Reply

    Hi , I used your code in , but when running on localhost , I get the following error message:

    Cannot display image “http : //localhost/countdown/index.php/root/datos/animate ” because it contains errors.
    Any clue what’s the problem ? Greetings from Mexico .

  4. frank
    frank at | | Reply

    does anybody have a solution using java and jsp?

  5. Rod Snyder
    Rod Snyder at | | Reply

    I noticed on the demo image above that the minutes sometimes increment by one minute. Seems to be somewhat random … no real pattern to it. It does it on my server also, running php5.2. Has anyone found a fix for this?

  6. Brian Begun
    Brian Begun at | | Reply

    Thanks again for the help Sean. It appears the preg_match code did the trick. If you are manually adjusting each character separately, you have to tweak the parameters to make preg_match work however:

    (preg_match(‘/^[0-9]$/’, $text))

    I also integrated the letter spacing code from here:

    The only problem I’m running into is that the characters seem to justify left. For the most part it isn’t that big of a deal, but everytime a number hits a “1” then the clock shifts too much to the left. It is more or less pronounced depending on the font used.

    It seems the only way to align/justify the text is to use a imagettfbox() function.

  7. Brian Begun
    Brian Begun at | | Reply

    Read back on the old comments, and saw why you set it to %a (sorry still waking up here). That seems to have the day value run properly but it isn’t padding to 2 digits when the days remaining are less than 10.

  8. Brian Begun
    Brian Begun at | | Reply

    More experimentation and this is what happens: I thought changing the lower case %a for days to %D fixed the padding issue, which it did. However, when I change the day out more than a day, it doesn’t update..I go back to the %a and it will update the day properly…arg

    Help please.

  9. Brian Begun
    Brian Begun at | | Reply

    Okay, sorry for the several updates, but I figured it out. In gif.php you have the following:
    $text = $interval->format(‘%a:%H:%I:%S’);

    It appears changing %a to %D for the day format gives me the two digits:
    $text = $interval->format(‘%D:%H:%I:%S’);

    Thanks again for putting this together! 🙂

  10. Brian Begun
    Brian Begun at | | Reply

    One more update: Okay so it appears the first digit of “days” is missing only when it’s zero. When I have a countdown that is farther than 1 day away it shows both digits. Also, because that first digit is missing from “days” it’s shifting the position of all the text, so it appears lined up when the there is more than one day remaining..

  11. Brian Begun
    Brian Begun at | | Reply

    small update: I was able to offset the text by using the “x-offset” value in gif.php, but it appears the first digit of the “days” value is missing..

  12. Brian Begun
    Brian Begun at | | Reply

    Heya SeanJA thanks for putting this together. I really want a countdown clock for my email that is gonna go out for a kickstarter project at the end of the summer. I saved the 3 .php files and .png background image into a folder. How do you get it to work? I tried pointing a browser to the gif.php file, but it just errors out. I tried the other working examples, and their gif.php file seems to be compiled or something. Am I missing something?

    1. daniel gonzalez
      daniel gonzalez at | | Reply

      Hi , I have tested the code of the countdown gif, but I can not make it work, in effect , creates animated gif, but does not show me in the browser , you had some difficulty making it work the code ? thank you very much

  13. Dan Hollings
    Dan Hollings at | | Reply

    How do you set the time with this code?

    I understand it is in a format like: time=2013-05-18+02:00:00 however, I cannot seem to get it to countdown from dates further out than 30 days. Any insight?

Leave a Reply