Skip to content

Instantly share code, notes, and snippets.

@Nukeer
Last active January 26, 2021 17:35
Show Gist options
  • Save Nukeer/986917c77c11f4f56da683df48343bfc to your computer and use it in GitHub Desktop.
Save Nukeer/986917c77c11f4f56da683df48343bfc to your computer and use it in GitHub Desktop.
get array of days in month
import { getYear } from 'date-fns';
getDaysInMonth(month): Array<number> {
const date = new Date(getYear(new Date()), month, 1);
const days = [];
while (date.getMonth() === month) {
days.push({ name: new Date(date).getDate() });
date.setDate(date.getDate() + 1);
}
return days;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment