2

I am using react-countdown-timer to display a counter in my React app. I want the timer to always use EST to compare as current time even if the page is loaded in any other time-zone.

In the documentation, I do see that it accepts a custom now() handler to which I can pass my time to. I used Moment-timezone to convert the current timezone in EST but the problem is that the now() handler for react-countdown-timer only takes time in Date.now() function's format which is the same in whichever timezone.

How can I implement this use case? I think there are 2 ways:

  1. To convert Moment() time in EST and then convert it into appropriate milliseconds
  2. To make react-countdown-timer accept other formats of data for it's now() handler.

How can this be implemented? Current code:

<Text mx={2} bold color='white'>Only LEFT <Countdown date={expire} now={() => {
    let z = Moment().tz('America/New_York').format('x')
    return z
}} />
Arihant
  • 3,847
  • 16
  • 55
  • 86

0 Answers0