FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
date-fns Has a Free API — Here's How to Handle Dates Without Moment.js
How-ToWeb Development

date-fns Has a Free API — Here's How to Handle Dates Without Moment.js

via Dev.to WebdevAlex Spinov2h ago

date-fns is a modern JavaScript date utility library with 200+ tree-shakeable functions for parsing, formatting, and manipulating dates. Installation npm install date-fns Formatting import { format , formatDistance , formatRelative } from " date-fns " ; const now = new Date (); console . log ( format ( now , " yyyy-MM-dd HH:mm:ss " )); // 2026-03-29 14:30:00 console . log ( format ( now , " EEEE, MMMM do yyyy " )); // Saturday, March 29th 2026 console . log ( formatDistance ( new Date ( 2026 , 2 , 25 ), now , { addSuffix : true })); // 4 days ago Parsing import { parse , parseISO , isValid } from " date-fns " ; const date1 = parseISO ( " 2026-03-29T10:00:00Z " ); const date2 = parse ( " 29/03/2026 " , " dd/MM/yyyy " , new Date ()); console . log ( isValid ( date1 )); // true Comparison import { isBefore , isAfter , differenceInDays , isWithinInterval } from " date-fns " ; const start = new Date ( 2026 , 0 , 1 ); const end = new Date ( 2026 , 11 , 31 ); console . log ( differenceInDays

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
0 views

Related Articles

How-To

10 Things Every Software Developer Should Know (But Most Ignore)

Medium Programming • 44m ago

The Deceptively Tricky Art of Designing a Steering Wheel
How-To

The Deceptively Tricky Art of Designing a Steering Wheel

Wired • 1h ago

7 Wireshark Filters That Instantly Make You Look Like a Network Expert
How-To

7 Wireshark Filters That Instantly Make You Look Like a Network Expert

Medium Programming • 2h ago

Week 6 — No New Problems. Just Me and Everything I Already Learned.
How-To

Week 6 — No New Problems. Just Me and Everything I Already Learned.

Medium Programming • 7h ago

What OpenClaw Gets Wrong Out of the Box (And How to Fix It)
How-To

What OpenClaw Gets Wrong Out of the Box (And How to Fix It)

Medium Programming • 8h ago

Discover More Articles