Skip to content

Instantly share code, notes, and snippets.

@anthonybrown
Last active December 2, 2018 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonybrown/519ce470f452ad29b2b566fc8ccc58d8 to your computer and use it in GitHub Desktop.
Save anthonybrown/519ce470f452ad29b2b566fc8ccc58d8 to your computer and use it in GitHub Desktop.
Using Array.from to compose dates
Array.from({ length: 12 }, (x, index) => (new Date(0, index).toLocaleString('us-EN', { month: '2-digit' })));
Array.from({ length: 12 }, (x, index) => (new Date(0, index).toLocaleString('us-EN', { month: 'long' })));
Array.from({ length: 12 }, (x, index) => (new Date(0, index).toLocaleDateString('us-EN', {weekday: 'long'})))
Array.from({ length: 12 }, (x, index) => (new Date(0, index).toLocaleString('us-EN', { month: 'narrow' })));
Array.from({ length: 12 }, (x, index) => (new Date(0, index).toLocaleDateString('us-EN', {weekday: 'narrow'})));
Array.from({ length: 12 }, (x, index) => (new Date(0, index).toLocaleString('us-EN', { month: 'short' })));
Array.from({ length: 12 }, (x, index) => (new Date(0, index).toLocaleDateString('us-EN', {weekday: 'short'})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment