Skip to content

Commit

Permalink
Use .padStart(2,0) to prefix one-digit numbers with zero
Browse files Browse the repository at this point in the history
  • Loading branch information
mhxbe committed Sep 22, 2019
1 parent 5219462 commit f04ab3e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils.js
Expand Up @@ -44,7 +44,7 @@ exports.getCurrentTime = function () {
const year = time.getFullYear();
const month = MONTHS[time.getMonth()];
const day = time.getDate();
const hour = `0${time.getHours()}`.slice(-2);
const minute = `0${time.getMinutes()}`.slice(-2);
const hour = `${time.getHours()}`.padStart(2,0);
const minute = `${time.getMinutes()}`.padStart(2,0);
return `${day} ${month} ${year} at ${hour}:${minute}`;
};

0 comments on commit f04ab3e

Please sign in to comment.