Skip to content

Instantly share code, notes, and snippets.

@hossammourad
Last active August 23, 2018 19:34
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 hossammourad/a4ebd2d30229805635fb96b61f53c62c to your computer and use it in GitHub Desktop.
Save hossammourad/a4ebd2d30229805635fb96b61f53c62c to your computer and use it in GitHub Desktop.
Format date using moment and locale
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