Skip to content

Instantly share code, notes, and snippets.

@ramirezsandin
Created August 19, 2022 09:25
Show Gist options
  • Save ramirezsandin/907b599eef2b2d495985201ae05d2ff6 to your computer and use it in GitHub Desktop.
Save ramirezsandin/907b599eef2b2d495985201ae05d2ff6 to your computer and use it in GitHub Desktop.
Helper funcctions to work with dates
export const formatToHTMLInput = (date: Date) => {
const year = date.getFullYear();
const month = date.getMonth();
const day = date.getDate();
return `${year}-${`0${month}`.slice(-2)}-${`0${day}`.slice(-2)}`;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment