Skip to content

Instantly share code, notes, and snippets.

@michaeloyer
Last active February 24, 2023 14:42
Show Gist options
  • Save michaeloyer/87eede65143b9a59261f16113e3665c1 to your computer and use it in GitHub Desktop.
Save michaeloyer/87eede65143b9a59261f16113e3665c1 to your computer and use it in GitHub Desktop.
Javascript DateString in the format yyyy-mm-dd
function toDateString(date) {
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
return `${year}-${month.toString().padStart(2,'0')}-${day.toString().padStart(2,'0')}`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment