DEV Community

Lumin
Lumin

Posted on

16 3

Get first date and last date of months with date-fns

Do not wasted time with native Date, use date-fns and go home!

import { format, lastDayOfMonth } from 'date-fns'

const today = new Date()
const firstDateOfMonth = format(today, 'yyyy-MM-01')
const lastDateOfMonth = format(lastDayOfMonth(today), 'yyyy-MM-dd')
Enter fullscreen mode Exit fullscreen mode

Now go home!

Top comments (1)

Collapse
 
codetobuild profile image
codetobuild

This post is like a flash of insight! It's short, clear, and gets right to the point. No extra stuff to bog you down. Time to call it a day and head home!

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up