Logo

dev-resources.site

for different kinds of informations.

Introducing date-formatter-i18n: Simplify i18n for Dates in JavaScript

Published at
1/10/2025
Categories
i18n
npm
javascript
localization
Author
elabid_asmaa
Categories
4 categories in total
i18n
open
npm
open
javascript
open
localization
open
Author
12 person written this
elabid_asmaa
open
Introducing date-formatter-i18n: Simplify i18n for Dates in JavaScript

As developers, we often deal with dates in our applications, and it’s never as simple as it seems. What format should we use? How do we account for user locales? What about relative time like "3 days ago"?

Introducing date-formatter-i18n, a lightweight NPM package that makes date formatting and localization effortless.

Here’s what it offers:


Features

  • πŸ“… Date Formatting: Convert raw dates into readable formats across locales.

  • ⏳ Relative Time: Display times like "2 days ago" or "in 1 hour" dynamically.

  • 🌍 i18n Support: Easily switch between languages like English, French, and German.


Why Use This Library?

Existing solutions can be heavy, complex, or lack proper i18n support. date-formatter-localized focuses on simplicity, making it perfect for multilingual apps.

Here’s an example:

import DateFormatter from 'date-formatter-i18n';

// Create an instance of DateFormatter
const dateFormatter = new DateFormatter('en');

const formattedDate = dateFormatter.format('2023-12-25'); 
// Output: "December 25, 2023"

// Relative time
const pastDate = new Date(Date.now() - 3 * 24 * 60 * 60 * 1000);
console.log(dateFormatter.formatRelative(pastDate));
// Output: 3 days ago

Enter fullscreen mode Exit fullscreen mode

Get Started

To install:

npm install date-formatter-localized


Contribute

Want to add more locales or features? Head over to the GitHub repo and contribute!

If you find it helpful, please star ⭐ the repository to show your support!

Let’s make date formatting smarter, simpler, and more global. 🌐

i18n Article's
30 articles in total
Favicon
Integration for FormatJS/react-intl: Automated Translations with doloc
Favicon
Introducing date-formatter-i18n: Simplify i18n for Dates in JavaScript
Favicon
Implementing i18n in Next.js - A Complete Guide to next-intl with App Router
Favicon
Integration for Angular: Automated Translations with doloc
Favicon
I18n vue
Favicon
Automating i18n Localization with AI: The Prismy Approach
Favicon
Integrating and storing the selected user language into the database in a full-stack application on "Angular" and "NestJS"
Favicon
πŸŽ„ Instant Local Translation with Chrome 🌐
Favicon
ICU vs. i18next: Choosing the Right Format for Your Localization Needs
Favicon
LiveCodes Gets a Fresh Look, and Goes Multilingual!
Favicon
A Modern Approach to Software Localization (2024)
Favicon
Pseudolocalization in Phoenix with gettext_pseudolocalize
Favicon
Launching YAMLFish, a simple translations management tool
Favicon
Mastering RTL with One Line of CSS (No Libraries Needed!) πŸš€
Favicon
Auto-Detect RTL in React with TypeScript! 🌐
Favicon
Is Your CSS Logical?
Favicon
Automation and branches- Using YAMLFish to easily manage I18n translations in your project
Favicon
The basics - Using YAMLFish to easily manage I18n translations in your project
Favicon
App Localization with doloc
Favicon
Software Localization Checklist
Favicon
Maneira simples de adicionar suporte a i18n no Rust com exemplos e testes
Favicon
Manera simple de agregar soporte i18n en Rust con ejemplos y pruebas
Favicon
Simple way to make i18n support in Rust with with examples and tests
Favicon
Reliable date formatting in Next.js
Favicon
Even a mouse can do i18n
Favicon
A Simple Way to Handle Locale-Specific URLs in Express
Favicon
Wagtail programmatically create page translation
Favicon
I18n Localization for Nuxt.js ! Implement multi-language support to website.
Favicon
Simplify Localization
Favicon
Comparing Language Detection Libraries (& API) Using Java/ColdFusion/CFML

Featured ones: