Mathemagician
Mathemagician

Reputation: 507

See if current date is between some months with momentJs

I'm using Moment.js to manipulate date format in my application and I would like to know how could I see if a my current date is between 31/08 and 30/09 (day/month) of the same year.

For example :

Upvotes: 0

Views: 250

Answers (1)

pablochan
pablochan

Reputation: 5715

Seems simple enough:

var isInRange = date.month() === 8 || (date.month() === 7 && date.date() === 31)

Note that months are indexed from 0.

Upvotes: 1

Related Questions