Article written by

24 Responses

Page 1 of 1
  1. 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?

  2. 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:

    http://stackoverflow.com/questions/6926613/php-imagettftext-letter-spacing

    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.

  3. 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.

  4. 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.

  5. 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! :-)

  6. 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..

  7. 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..

  8. 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?

  9. 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