Skip to content

Instantly share code, notes, and snippets.

@ivandez
Created July 12, 2022 20:23
Show Gist options
  • Save ivandez/39b06478d5565225fd35ea90036a1436 to your computer and use it in GitHub Desktop.
Save ivandez/39b06478d5565225fd35ea90036a1436 to your computer and use it in GitHub Desktop.
function to convert Date into string formart TS
private formatDate = (date: Date): string => {
const formatedDate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
const formatedTtime = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
const dateTime = formatedDate + " " + formatedTtime;
return dateTime;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment