Skip to content

Instantly share code, notes, and snippets.

@jkeefe
Created April 29, 2022 20:00
Show Gist options
  • Save jkeefe/5c4ae5d8b83f43a47a9ac474b034e20d to your computer and use it in GitHub Desktop.
Save jkeefe/5c4ae5d8b83f43a47a9ac474b034e20d to your computer and use it in GitHub Desktop.
Test to see if a date is the last day of the month with dayjs()
const dayjs = require('dayjs')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat)
const reading_date = dayjs(reading.t, 'M/D/YYYY HH:mm:ss A')
// is the month of adding a day the same as the month of adding a month?
if ( reading_date.add(1, 'day').get('month') == reading_date.add(1, 'month').get('month') ){
console.log(reading.t)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment