0

I have two buttons for cycling through months (next, previous) and a paragraph next to it which displays the month as in "October 2018".

I'd like to append the date to URL on button click such as ?dateFrom=01-10-2018&dateTo=31-10-2018

How could I recognize what my next or previous month is and whether it has 30 or 31 days without hard coding every possible option?

F.Ciber
  • 3
  • 2
  • You have asked more than one question within your post. As such, it is too broad. Narrow down your question to a specific issue. – Taplar Nov 07 '18 at 15:41
  • 1
    javascript return client system time that may be not set. I think you should get date from server to get correct result. – Mohammad Nov 07 '18 at 15:49
  • 1
    Look for [moment.js](https://momentjs.com/) -- February sometime has 29 days too ;) – Louys Patrice Bessette Nov 07 '18 at 15:49
  • For most scenarios, I agree with @Mohammad. If accuracy isn't important, another good JS date library: [date-fns](https://date-fns.org/) – jchook Nov 07 '18 at 15:50
  • Possible duplicate of [What is the best way to determine the number of days in a month with JavaScript?](https://stackoverflow.com/questions/315760/what-is-the-best-way-to-determine-the-number-of-days-in-a-month-with-javascript) – showdev Mar 08 '19 at 13:41

0 Answers0