Skip to content

Commit

Permalink
feat: add formatDate
Browse files Browse the repository at this point in the history
  • Loading branch information
victory-sokolov committed Apr 3, 2024
1 parent 6f171d2 commit 46077d3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ export const getMonthList = () => {
});
};

/**
* Format date to YY-MM-DD format
* @param date
* @returns YY-MM-DD string
*/
export const formatDate = (date: Date) => {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
return `${year}-${month}-${day}`;
};

/**
* Convert Date to date with timestamp separated with dashes
* @param date Date to convert
Expand Down

0 comments on commit 46077d3

Please sign in to comment.