Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created June 26, 2020 12:34
Show Gist options
  • Save velotiotech/bf8508c9de1121e5aa66064945884799 to your computer and use it in GitHub Desktop.
Save velotiotech/bf8508c9de1121e5aa66064945884799 to your computer and use it in GitHub Desktop.
export const formatDate = (date) => {
var d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2)
month = '0' + month;
if (day.length < 2)
day = '0' + day;
return [year, month, day].join('-');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment