Menu

1 / 2

date-light: A 1.8KB Alternative to date-fns You Might Actually Like

DEV Community: typescript·날다람쥐·6 months ago
#faZrRqBh
#dev#date#light#functions#faster
Reading 0:00
15s threshold

If you've ever shipped a frontend app and watched your bundle bloat because of date utilities, you're not alone. date-fns is fantastic — but importing 20 functions costs you 18 KB. dayjs is lighter at 3 KB, but it wraps every Date in a mutable object.

I wanted something different: pure functions, zero dependencies, and a bundle so small you forget it's there.

That's date-light .

What is it?

date-light is a zero-dependency, fully typed date utility library for JavaScript and TypeScript. It covers the 20 most-used date-fns operations with 39 functions — and the entire thing weighs 1.79 KB minzipped .

npm install date-light

Enter fullscreen mode

Exit fullscreen mode

import { format , addDays , differenceInDays , isBefore , startOfDay } from " date-light " ;

const date = new Date ( 2026 , 5 , 30 , 14 , 30 , 45 );

format ( date , " yyyy-MM-dd HH:mm:ss " ); // "2026-06-30 14:30:45" addDays ( date , 7 ); // Tue Jul 07 2026 differenceInDays ( date , new Date ( 2026 , 0 , 1 )); // 180 isBefore ( date , new…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.