Created
July 14, 2017 11:54
-
-
Save DanWebb/8f9452391f79b6d6827caae2536829b6 to your computer and use it in GitHub Desktop.
International date format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default date => { | |
const monthNames = [ | |
'Jan', | |
'Feb', | |
'Mar', | |
'Apr', | |
'May', | |
'Jun', | |
'Jul', | |
'Aug', | |
'Sep', | |
'Oct', | |
'Nov', | |
'Dec' | |
]; | |
if (date) { | |
date = new Date(date); | |
} else { | |
date = new Date(); | |
} | |
return `${date.getDate()} ${monthNames[date.getMonth()]} ${date.getFullYear()}`; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment