fixmint
EN

How to add a free countdown timer to your website

To add a countdown to your website, open the widgets page, choose a colour and theme, press Copy code, paste it into your page and change two things: the data-date value, which is the moment it counts down to, and the title above the numbers. If visitors live in more than one time zone, also give the date a time zone, or each visitor gets a different finish line.

Date calculatorHow many days until…?Do it free

How to set the date and the words

The countdown is one <div> with a data-date attribute, followed by a style block and a script. The copied snippet counts down to 2027-01-01T00:00:00. The format is year-month-day, the letter T, then hour:minute:second on a 24-hour clock.

Change three things:

  1. data-date on the outer <div>: your launch, sale or event.
  2. The title. It reads "Countdown to New Year 2027". Replace it, or your page will keep saying New Year.
  3. The message at zero. When the time is up the numbers stay at 0 and the line "It's here." appears. It is plain text in the snippet, so you can change it to "The sale has started" or remove it.

The widget shows days, hours, minutes and seconds and updates every second. The words "days", "hours" and so on are also plain text you can translate. Each countdown on a page reads its own data-date, so you can place several. For the colour and theme options and what pasting looks like in WordPress, Squarespace, Wix and Webflow, see how to add a calculator to your website. It is the same for every widget.

Time zones: when does it reach zero for each visitor?

This is the part that goes wrong. A date and time written without a time zone, like 2027-01-01T00:00:00, is read as local time on the visitor's own device. In a test with two device time zones, midnight on 1 January 2027 in Tokyo is 15:00 UTC on 31 December. In New York it is 05:00 UTC on 1 January. The two countdowns finish 14 hours apart.

For New Year that is right: everyone wants their own midnight. For a sale that opens at 9:00 in your shop's time zone, a webinar or a product launch, it is wrong, because the moment is the same for everybody and only the clock on the wall differs.

To fix a single moment for everyone, put the time zone inside the date:

  • 2027-01-01T09:00:00-05:00 is 9:00 at a place that is five hours behind UTC, such as New York in winter. It equals 14:00 UTC.
  • 2027-01-01T14:00:00Z is the same moment written in UTC. The Z stands for UTC.

Two traps:

  • The offset changes with daylight saving. New York is -05:00 in January and -04:00 in July. Use the offset that applies on the day you count down to, not today's. The time zone converter shows one moment in several cities, each with its offset from UTC. Why meeting times shift twice a year and EST, EDT or ET explain the rest.
  • A date alone is read as UTC, not local. 2027-01-01 with no time means midnight UTC, so a visitor in New York sees the countdown end at 7 p.m. on 31 December. A date with a time and no zone is local; a date with no time is UTC. Always write both the time and the zone.

The countdown also measures against the visitor's device clock. If someone's clock is wrong, their countdown is wrong by the same amount. A countdown is a good reminder, not a judge of exactly when a sale opens: let your shop or server decide that.

Show the time in other cities: the world clock

When your event has one start time, a world clock widget answers "what time is that for me?" It lists cities, each with the time, the short weekday and the offset from UTC, for example GMT-5. The list is plain HTML: every row looks like <li data-zone="America/New_York">New York</li>. Change the data-zone value to any standard zone name, such as Europe/Berlin or Australia/Sydney, and change the visible name to match.

The times come from the browser's own time zone data, so daylight saving is applied by the browser. The rows refresh every 15 seconds. The time and the weekday are written in the language of your page's lang attribute.

Place it under a countdown whose date has an explicit zone, and visitors see both the wait and their own local start time. The date calculator works out how many days lie between two dates if you want to put the number in the text as well.

A timer instead of a date

For something that starts when the visitor presses a button, use the timer widget. It has presets for 1, 5, 10 and 25 minutes, Start, Pause, Resume and Reset, a progress bar and a soft beep at the end. It suits a quiz, a recipe, a study page or a workout. To change the presets, edit the data-min number and the label of each button.

Both the timer and the countdown work out the time left from the clock, not by counting ticks. If a browser slows a background tab, the numbers are right again when the visitor returns. The same idea is explained in why browser timers drift. For a stopwatch with laps, open the online timer.

Before the page goes live

  • Write the date in words as well. A line like "Sale opens 1 December, 9:00 New York time" helps visitors whose browser blocks scripts, who then see dashes where the numbers should be. It also tells search engines and readers when the event is.
  • Look at the phone. Four boxes sit in a row. Check they fit at your visitors' phone width, with the biggest number you expect.
  • Remove it afterwards. A countdown stuck on zero long after the event makes a page look abandoned. Replace the widget or change the date.

Prefer commands to widgets? The same site has a command-line program with twenty tools for your own computer.

Know someone with the same problem? Send them this article.

Comments

    No comments yet. Be the first.

    Your rating (optional)
    0 / 300

    Your email is never shown or kept.

    Cover of Digital Workflow ToolkitDigital Workflow Toolkit

    Recipes, templates and patterns for chaining small file jobs (convert, rename, compress, merge) into workflows that run the same way every time.

    $19.00Get it on Gumroad