date-fns

Standardize date formatting, parsing, and relative-time display across a monorepo.

Updated May 7, 2026
One-click install
npx skills add https://github.com/johinsDev/loyalty-app --skill date-fns-johinsdev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: date-fns
Source: https://github.com/johinsDev/loyalty-app/tree/main/.claude/skills/date-fns
Command: npx skills add https://github.com/johinsDev/loyalty-app --skill date-fns-johinsdev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It prevents inconsistent and broken date formatting/parsing across the monorepo, including the common “Invalid Date” and wrong-locale/UTC-vs-local-midnight bugs.

Core Features & Use Cases

  • Single, consistent date API: format, parse, validate, and range helpers so UI and routes don’t diverge.
  • Locale-aware rendering: resolves locale from next-intl locale codes so English/Spanish output stays correct.
  • Safer parsing + relative time: parseDate returns null for garbage input, and RelativeTime renders SSR-safe “x minutes ago” with adaptive ticking and no hydration mismatch.
  • Use cases: fixing “Invalid Date” in the UI, adding date columns, building “hace 3 minutos” strings, or parsing user-entered/query-provided dates reliably.

Quick Start

Import and use date helpers from @loyalty/date in your Next.js components and pass the current locale, then use @loyalty/date/react RelativeTime when displaying “time ago”.

Frequently Asked Questions about date-fns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix Invalid Date errors in Next.js date columns?

To fix Invalid Date errors in Next.js, use a standardized date API with null-safe parsing to return null for invalid input. This prevents broken date rendering across UI columns and query parameters.

How do I display relative time in Next.js without hydration mismatch?

To display relative time without hydration mismatch, use an SSR-safe RelativeTime component. It renders "x minutes ago" strings with adaptive ticking and hydration-safe behavior to prevent server-client rendering inconsistencies.

How do I format dates with next-intl locale resolution in a monorepo?

To format dates with next-intl locale resolution, import formatting helpers through a centralized date module. This resolves locale codes so English and Spanish date output stays correct across both server and client components.

What is the best way to standardize date formatting across a monorepo?

The best way to standardize date formatting across a monorepo is enforcing a single date API for formatting, parsing, and validation. This ensures UI components and routes do not diverge on locale-correct output and UTC-vs-local-midnight bugs.

Can I parse user-entered dates safely without throwing errors?

Yes, you can parse user-entered dates safely by using a null-safe parseDate function. It handles user input and query parameters by returning null for garbage input instead of throwing runtime errors.