Use Moment And Moment Timezone To Properly Implement Diff
Trying to use moment's diff function to calculate ms difference in time b/w one moment that will always have a constant timezone and another timezone indifferent moment. I'm using
Solution 1:
I think you want to compute the difference between today at 18:00 Paris time and now. That would be
moment.tz('18:00', 'HH:mm', 'Europe/Paris').diff(moment());
Basically, you need to parse 18:00 as Paris time. What is happening right now is that you are parsing it as local time, and then converting that to Paris time.
Note that because you aren't specifying a date, the day is assumed to be 'today', meaning that this code can result in both positive and negative values.
See this blog post for more information about how moment's constructor functions work.
Post a Comment for "Use Moment And Moment Timezone To Properly Implement Diff"