1

I'm writing a script that doing some date manipulation and I need to know how many days between current date and end of the month.

I've already got a function that I can put two dates into and it'll return the number of days between the two dates.

I'm looking for an equivalent of EOMONTH in scripts so I can return the date of the last day of any given month (Hope that makes sense)

All I've been able to come up with so far is adding a day to the date until it becomes a new month and running a counter whilst doing so, but this just seems a really silly way of doing it.

Michael Liew
  • 273
  • 3
  • 12

1 Answers1

1
function daysInMonth(m=0) {
  return new Date(new Date().getFullYear(),m+1,0).getDate();
}
Cooper
  • 59,616
  • 6
  • 23
  • 54