Use MomentJS to display a countdown accordingly to the selected timezone no matter the localtime your computer is.
HTML:
JS:
Feature read
Why use MomentJS
The JavaScript Date
object has support for timezones, but by default are naive β does not have any information about the timezone β and are localized according to where is run:
The JavaScript Date object supports a number of UTC (universal) methods, as well as local time methods. UTC, also known as Greenwich Mean Time (GMT), refers to the time as set by the World Time Standard. The local time is the time known to the computer where JavaScript is executed.
β From: Mozilla Developer Network
MomentJS is a great piece of open-source project, is stable, well maintained and have a great support to manage and convert the timezone aware Date
objects. Is good to remember that itβs a best practice to always store and retreive dates from the server in the UTC.
From the beginning, this project aimed to create an easy to use and customizable countdown plugin, people often have a hard time do disassociate the timezone problem from the former because they look the same but they are not.
Keep in mind that this project will NEVER support a timezone aware version out-of-the box.