Skip to content

Instantly share code, notes, and snippets.

@MultiMote
Last active June 15, 2022 07:16
Show Gist options
  • Save MultiMote/05d7f5a278043b24f776f114371ae660 to your computer and use it in GitHub Desktop.
Save MultiMote/05d7f5a278043b24f776f114371ae660 to your computer and use it in GitHub Desktop.
Get season name from month
const month = new Date().getMonth(); // 0-11
const seasons = ['winter', 'spring', 'summer', 'autumn'];
const seasonIndex = Math.floor(((month + 1) % 12) / 3);
const seasonName = seasons[seasonIndex];
console.log(seasonName);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment