Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Created October 27, 2015 13:01
Show Gist options
  • Save andreasvirkus/3fc9eae0ea69cbebbc8f to your computer and use it in GitHub Desktop.
Save andreasvirkus/3fc9eae0ea69cbebbc8f to your computer and use it in GitHub Desktop.
/**
* Get the numeric equivalent of an English (shortened) month name
*
* It's best to keep the English version in the element's data
* attribute when dealing with translatable strings.
*
* @param monthStr long or short month name
* @returns {number} month's integer equivalent (1-12)
*/
function getMonth(monthStr){
return new Date('1 ' + monthStr + ' 2001').getMonth() + 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment