Last active
August 23, 2018 19:34
-
-
Save hossammourad/a4ebd2d30229805635fb96b61f53c62c to your computer and use it in GitHub Desktop.
Format date using moment and locale
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
import moment from 'moment'; | |
export default ({ year, month, day }) => { | |
const locale = 'en-US'; | |
const val = moment() | |
.year(year) | |
.month(month) | |
.date(day); | |
moment.locale(locale); | |
const formatter = moment.localeData().longDateFormat('L'); | |
return moment(val).format(formatter); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment