Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save muhrusdi/b9b5ba5af808e2603a9ce29558cdab66 to your computer and use it in GitHub Desktop.
Save muhrusdi/b9b5ba5af808e2603a9ce29558cdab66 to your computer and use it in GitHub Desktop.
const months = useMemo(() => {
return new Array(12).fill(null).map((n, i) => {
return format(new Date(new Date().getFullYear(), i), "MMM")
})
}, [])
const years = useMemo(() => {
const y = new Array(10).fill(null)
const min = new Date().getFullYear() - y.length
return y
.map((n, i) => {
return format(new Date(min + i + 1, i), "yyyy")
})
.reverse()
}, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment