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

Lumin @ilumin

Location:
Bangkok, Thailand
Joined:
Jan 25, 2018

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

Publish Date: Jun 7 '22
20 1

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!

Comments 1 total

  • codetobuild
    codetobuildMay 2, 2024

    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!

Add comment