Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

moment-timezone 0.5.45

Parse and display moments in any timezone.
Package summary
Share
0
issues
0
licenses
Package created
7 Jul 2013
Version published
4 Feb 2024
Maintainers
7
Total deps
0
Direct deps
0
License
MIT
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does moment-timezone do?

Moment-timezone is an npm package that provides IANA time zone support for Moment.js, a popular library for managing dates and times in JavaScript. It's an add-on that allows developers to parse, manipulate, and display moments in any timezone. It is, however, considered a legacy project and is in maintenance mode with most users encouraged to choose a different library.

How do you use moment-timezone?

The usage of Moment-timezone is quite straightforward. It lets you manipulate and display dates and times in JavaScript based on different time zones. Specifically, you would use Moment.js to create a moment object, and then use Moment-timezone to convert and format that moment object into a specific timezone.

An example of usage is as follows:

var moment = require('moment-timezone'); // require the moment-timezone package
var june = moment("2014-06-01T12:00:00Z"); 
june.tz('America/Los_Angeles').format('ha z'); // the output is "5am PDT"

In this example, we first require the moment-timezone library. We then create a moment object for a specific date and time (June 1, 2014, at 12:00:00 UTC). Finally, we use the .tz() method to convert the moment object's time to the "America/Los_Angeles" timezone, and the .format() method to display the time in a specific format ("ha z" gives the hour in 12-hour format and the timezone abbreviation).

Where are the moment-timezone docs?

For comprehensive documentation on Moment-timezone, you can refer to the official documentation provided by Moment.js. It covers everything from basic usage to more advanced topics, along with detailed explanations and code examples to help understand the usage of each method and feature.