Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@formatjs/intl-datetimeformat

Package Overview
Dependencies
Maintainers
3
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@formatjs/intl-datetimeformat

Intl.DateTimeFormat polyfill

  • 2.6.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
194K
decreased by-5.86%
Maintainers
3
Weekly downloads
 
Created

What is @formatjs/intl-datetimeformat?

@formatjs/intl-datetimeformat is a JavaScript library that provides a robust and flexible way to format dates and times according to the Internationalization API. It extends the capabilities of the native `Intl.DateTimeFormat` object, offering additional features and customization options for developers to format dates and times in a variety of locales and styles.

What are @formatjs/intl-datetimeformat's main functionalities?

Basic Date Formatting

This feature allows you to format dates according to a specified locale. In this example, the date is formatted in the 'en-US' locale.

const { DateTimeFormat } = require('@formatjs/intl-datetimeformat');
const dtf = new DateTimeFormat('en-US');
console.log(dtf.format(new Date()));

Custom Date Formatting

This feature allows you to customize the date format by specifying options such as year, month, and day. In this example, the date is formatted to show the full month name, numeric day, and numeric year.

const { DateTimeFormat } = require('@formatjs/intl-datetimeformat');
const dtf = new DateTimeFormat('en-US', { year: 'numeric', month: 'long', day: 'numeric' });
console.log(dtf.format(new Date()));

Time Formatting

This feature allows you to format time according to a specified locale and options. In this example, the time is formatted to show hours, minutes, and seconds.

const { DateTimeFormat } = require('@formatjs/intl-datetimeformat');
const dtf = new DateTimeFormat('en-US', { hour: 'numeric', minute: 'numeric', second: 'numeric' });
console.log(dtf.format(new Date()));

Locale-Sensitive Date and Time Formatting

This feature allows you to format both date and time in a locale-sensitive manner. In this example, the date and time are formatted according to the 'fr-FR' locale.

const { DateTimeFormat } = require('@formatjs/intl-datetimeformat');
const dtf = new DateTimeFormat('fr-FR', { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric' });
console.log(dtf.format(new Date()));

Other packages similar to @formatjs/intl-datetimeformat

Keywords

FAQs

Package last updated on 18 Sep 2020

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