Socket
Socket
Sign inDemoInstall

intl-relativeformat

Package Overview
Dependencies
Maintainers
4
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intl-relativeformat

Formats JavaScript dates to relative time strings.


Version published
Weekly downloads
137K
decreased by-21.48%
Maintainers
4
Weekly downloads
 
Created

What is intl-relativeformat?

The intl-relativeformat npm package is used for formatting relative dates and times in a human-readable way. It leverages the Internationalization API to provide locale-aware formatting, making it easier to display dates and times relative to the current date and time.

What are intl-relativeformat's main functionalities?

Basic Relative Time Formatting

This feature allows you to format a date relative to the current time. In this example, it formats a date that is one hour ago.

const IntlRelativeFormat = require('intl-relativeformat');
const rf = new IntlRelativeFormat('en');
console.log(rf.format(Date.now() - 1000 * 60 * 60)); // 'an hour ago'

Locale-Specific Formatting

This feature allows you to format dates relative to the current time in a locale-specific manner. In this example, it formats a date that is one hour ago in French.

const IntlRelativeFormat = require('intl-relativeformat');
const rf = new IntlRelativeFormat('fr');
console.log(rf.format(Date.now() - 1000 * 60 * 60)); // 'il y a une heure'

Future Date Formatting

This feature allows you to format future dates relative to the current time. In this example, it formats a date that is one hour in the future.

const IntlRelativeFormat = require('intl-relativeformat');
const rf = new IntlRelativeFormat('en');
console.log(rf.format(Date.now() + 1000 * 60 * 60)); // 'in an hour'

Other packages similar to intl-relativeformat

Keywords

FAQs

Package last updated on 03 Jun 2019

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