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:




  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
}} />









share|improve this question




























    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:




    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
    }} />









    share|improve this question


























      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:




      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
      }} />









      share|improve this question















      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
      }} />






      javascript reactjs momentjs moment-timezone






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 18 at 3:04

























      asked Nov 18 at 2:56









      Arihant

      1,29993151




      1,29993151





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          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






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Paul Cézanne

          UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

          Angular material date-picker (MatDatepicker) auto completes the date on focus out