Fri Aug 09 2024

How to Create Countdown Timer in React Component

Next.JS230 views

If you want to launch a new site or add new pages, a countdown timer is a great way to inform your users that your site is under construction and will be live soon. It creates anticipation and keeps visitors engaged, especially when paired with a visually appealing under-construction page. Here, we'll walk through a simple countdown timer component of a Next.js and TailwindCSS project.

Time left calculation from millisecond

  const dys = Math.floor(difference / (1000 * 60 * 60 * 24));
const hrs = Math.floor((difference / (1000 * 60 * 60)) % 24);
const mnt = Math.floor((difference / (1000 * 60)) % 60);
const snd = Math.floor((difference / 1000) % 60);

How to Create Countdown Timer in React Component
Reference:

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.