React countdown timer to run only on EST
up vote
1
down vote
favorite
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
}} />
javascript reactjs momentjs moment-timezone
add a comment |
up vote
1
down vote
favorite
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
}} />
javascript reactjs momentjs moment-timezone
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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
}} />
javascript reactjs momentjs moment-timezone
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
}} />
javascript reactjs momentjs moment-timezone
javascript reactjs momentjs moment-timezone
edited Nov 18 at 3:04
asked Nov 18 at 2:56
Arihant
1,29993151
1,29993151
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53357488%2freact-countdown-timer-to-run-only-on-est%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown