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