Skip to content

Commit

Permalink
Merge pull request #4 from ztjhz/main
Browse files Browse the repository at this point in the history
refactor: `getToday` (#281)
  • Loading branch information
jackschedel authored May 8, 2023
2 parents 766106f + f752a44 commit eb4ce4a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/utils/date.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
export const getToday = () => {
const date = new Date();
const dateString =
date.getFullYear() +
'-' +
('0' + (date.getMonth() + 1)).slice(-2) +
'-' +
('0' + date.getDate()).slice(-2);
return dateString;
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');

return `${year}-${month}-${day}`;
};

0 comments on commit eb4ce4a

Please sign in to comment.