Socket
Socket
Sign inDemoInstall

date-fns-tz

Package Overview
Dependencies
Maintainers
0
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-fns-tz

Time zone support for date-fns v3 with the Intl API


Version published
Weekly downloads
3.5M
increased by4.55%
Maintainers
0
Weekly downloads
 
Created

What is date-fns-tz?

The date-fns-tz package is a complementary library to date-fns that provides comprehensive timezone support for date manipulation. It allows users to parse and format dates in any timezone and provides utilities for working with zoned dates.

What are date-fns-tz's main functionalities?

Timezone-aware date parsing

This feature allows you to convert a local time string to a UTC date, taking into account the specified timezone.

import { zonedTimeToUtc } from 'date-fns-tz';
const date = zonedTimeToUtc('2023-04-01T12:00:00', 'America/New_York');

Timezone-aware date formatting

This feature allows you to format a UTC date to a string that represents the date and time in a specified timezone.

import { format } from 'date-fns';
import { utcToZonedTime, format } from 'date-fns-tz';
const date = new Date('2023-04-01T16:00:00Z');
const newYorkDate = utcToZonedTime(date, 'America/New_York');
const formattedDate = format(newYorkDate, 'yyyy-MM-dd HH:mm:ssXXX', { timeZone: 'America/New_York' });

Timezone conversion

This feature allows you to convert dates between UTC and a specified timezone.

import { utcToZonedTime, zonedTimeToUtc } from 'date-fns-tz';
const utcDate = new Date('2023-04-01T16:00:00Z');
const zonedDate = utcToZonedTime(utcDate, 'Europe/Berlin');
const backToUtc = zonedTimeToUtc(zonedDate, 'Europe/Berlin');

Other packages similar to date-fns-tz

Keywords

FAQs

Package last updated on 30 Sep 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc