Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
moment-timezone
Advanced tools
The moment-timezone package is an extension for the moment.js library that allows users to parse and display dates in any timezone. It provides timezone data and functions to work with dates in different time zones.
Parsing Dates in Timezones
This feature allows you to create a moment object with a specified timezone. The code sample creates a moment object for the time and date '2013-11-18 11:55' in the 'America/Toronto' timezone.
moment.tz('2013-11-18 11:55', 'America/Toronto')
Converting Dates to Different Timezones
This feature enables you to convert the current time to a different timezone. The code sample converts the current time to the 'America/New_York' timezone and formats it as a string.
moment().tz('America/New_York').format()
Retrieving Timezone Names
This feature provides a list of all the timezone names available in the moment-timezone library. The code sample retrieves an array of timezone names.
moment.tz.names()
Working with UTC Offsets
This feature allows you to work with UTC offsets directly. The code sample parses a date with a specific UTC offset and retrieves that offset in minutes.
moment.parseZone('2013-01-01T00:00:00-13:00').utcOffset()
date-fns-tz is a timezone support add-on for date-fns, a modern JavaScript date utility library. It provides similar functionalities for handling timezones but with a more modular approach, which can result in smaller bundle sizes if only specific functions are imported.
Luxon is a powerful, modern, and friendly wrapper for JavaScript dates and times. It includes comprehensive timezone support and compares to moment-timezone with a more fluent and chainable API, as well as being immutable, which can help prevent bugs in date-related code.
Day.js is a minimalist JavaScript library for parsing, validating, manipulating, and formatting dates, similar to moment.js. With its plugin 'utc' and 'timezone', it can provide similar timezone handling capabilities as moment-timezone, but with a smaller footprint and a simpler API.
Spacetime is a lightweight way to manipulate, traverse, compare, and format dates and times across planet Earth. It offers a different approach to handling timezones and date-time manipulation with a focus on performance and a smaller size compared to moment-timezone.
IANA Time Zone Database + Moment.js.
var june = moment("2014-06-01T12:00:00Z");
june.tz('America/Los_Angeles').format('ha z'); // 5am PDT
june.tz('America/New_York').format('ha z'); // 8am EDT
june.tz('Asia/Tokyo').format('ha z'); // 9pm JST
june.tz('Australia/Sydney').format('ha z'); // 10pm EST
var dec = moment("2014-12-01T12:00:00Z");
dec.tz('America/Los_Angeles').format('ha z'); // 4am PST
dec.tz('America/New_York').format('ha z'); // 7am EST
dec.tz('Asia/Tokyo').format('ha z'); // 9pm JST
dec.tz('Australia/Sydney').format('ha z'); // 11pm EST
0.3.1
2015-03-16
2015a
. #183FAQs
Parse and display moments in any timezone.
The npm package moment-timezone receives a total of 7,833,354 weekly downloads. As such, moment-timezone popularity was classified as popular.
We found that moment-timezone demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.