Created
November 14, 2019 20:21
-
-
Save raco/88765110a63490e7f74c95c404d6c444 to your computer and use it in GitHub Desktop.
Format date dd mm yyyy for dummies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
formatDate(_date: Date, separator = '/') { | |
const day = _date.getDate(); | |
const month = _date.getMonth() + 1; | |
const year = _date.getFullYear(); | |
if (month < 10) { | |
return `${day}${separator}0${month}${separator}${year}`; | |
} else { | |
return `${day}${separator}${month}${separator}${year}`; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment