Showing countdown timer in email

Last day I received an email newsletter which contained a countdown timer in it. It was quite interesting because most of the times emails are static and we are unable to show any dynamic data. Then again, there is the GIF image format which can show animated images. From investigating the source I figured that they are doing exactly that. They are using the service from a third party provider to create “countdown” GIF images.

So, I thought why not make one for myself. And I came up with a class to accept target time (end time of countdown) and some other parameters which will return an animated GIF image resource. We can then embed that image in the email and the email body will show a nice little countdown timer. More about the class and usage is available on GitHub.

Demo: A 15 minute timer

15 minutes

Fork the class from GitHub: https://github.com/ashiqur-rony/gif-timer

There is a catch though. As the timer creates a frame for each step (one frame per second in the above demo), this method is really resource hungry.

2 thoughts on “Showing countdown timer in email

  1. Nice work, however, I give it a try, it shows error message – Notice: A non well formed numeric value encountered on line “$background = ImageColorAllocate($image, $this->bg_color[0], $this->bg_color[1], $this->bg_color[2]);”? do you have any clue? thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.