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

intl-relativeformat

Package Overview
Dependencies
Maintainers
2
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.

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
149K
decreased by-10.16%
Maintainers
2
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 27 Oct 2015

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