---
description: >-
  https://stackoverflow.com/questions/13146418/find-all-the-days-in-a-month-with-date-object
---

# You can get the number of days in a specified month (ok)

```
const getAllDaysInMonth = (month, year) => Array.from({
					length: new Date(year, month, 0).getDate()
				},
				(_, i) => new Date(year, month - 1, i + 1));
			const allDatesInOctober = getAllDaysInMonth(3, 2022)
			console.log(allDatesInOctober.map(x => x.toLocaleDateString([], { month: "numeric", day: "numeric" })))
```

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1E4Gk2ppVKb4olmnun%2Fuploads%2F29g6wn2g597FaUNzjH3E%2FScreenshot_2.png?alt=media\&token=87e64aa3-d2c6-4781-b7b3-bba027b2eceb)
