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:
- To convert Moment() time in EST and then convert it into appropriate milliseconds
- 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
}} />