Working with US time zones always gets me confused.
I am not sure if it is especially hard for me because I grew up in a country with a single time zone and no daylight saving time, or if it is just hard for everyone.
Either way, I decided to write a simple command line tool to make it a little easier: timezones-cli.
To use it, you first install it with npm:
npm install -g timezones-cli
Then you can convert any datetime (in ISO-8601 format) to the equivalent time in the different US timezones:
You will get back a result with four columns:
UTC 2017-01-16 04:00 AM PST (-8:00) 2017-01-15 08:00 PM Los Angeles PDT/MST (-7:00) 2017-01-15 09:00 PM Phoenix, Denver CST/MDT (-6:00) 2017-01-15 10:00 PM Chicago CDT/EST (-5:00) 2017-01-15 11:00 PM New York EDT (-4:00) 2017-01-16 12:00 AM
- The timezone's abbreviation.
- The timezone's offset from UTC.
- The equivalent time in that timezone.
- Cities in that timezone at that specific time.
You can also pass a datetime in milliseconds, or pass no datetime at all (in that case, it will use your current time):
# use the current time timezones # use an epoch timestamp timezones 1505684849831
A Quick Recap on US Timezones
The continental USA uses four major timezones:
- Pacific Time Zone
- Mountain Time Zone
- Central Time Zone
- Eastern Time Zone
Each timezone is subdivided into:
- Standard Time — observed during autumn/winter.
- Daylight Saving Time — observed during spring/summer. One hour "ahead" of Standard Time.
Which leaves us with 8 timezones total:
- Pacific Standard Time (PST) -08:00
- Pacific Daylight Time (PDT) -07:00
- Mountain Standard Time (MST) -07:00
- Mountain Daylight Time (MDT) -06:00
- Central Standard Time (CST) -06:00
- Central Daylight Time (CDT) -05:00
- Eastern Standard Time (EST) -05:00
- Eastern Daylight Time (EDT) -04:00
Most of the United States begins Daylight Saving Time at 2:00 AM on the second Sunday in March and reverts to standard time at 2:00 AM on the first Sunday in November.
On December 1st, Los Angeles is on PST.
On April 1st, Los Angeles is on PDT.
However, not all cities observe Daylight Saving Time.
Phoenix, Arizona uses MST all year round.
The idea behind timezones-cli is to pack all of this information in a simple, easy-to-use format.
Roadmap, Bugs & Improvements
timezones-cli was written in a couple of hours to solve an issue I was personally having. It is a very simple script, powered by the amazing Moment Timezone library.
I decided to share it in case anyone else might find it useful.
If you end up using it and would like to see an improvement, feel free to create an Issue or submit a Pull Request to https://github.com/alexishevia/timezones-cli.