Created
November 14, 2020 19:04
-
-
Save iamso1/738af86b548b473581850f4ab310a578 to your computer and use it in GitHub Desktop.
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
const getFormattedTime = (dateObj) => { | |
const year = dateObj.getFullYear(); | |
const month = dateObj.getMonth().toString().padStart(2, 0); | |
const date = dateObj.getDate().toString().padStart(2, 0); | |
const hour = dateObj.getHours().toString().padStart(2, 0); | |
const min = dateObj.getMinutes().toString().padStart(2, 0); | |
const sec = dateObj.getSeconds().toString().padStart(2, 0); | |
const result = `${year}-${month}-${date}T${hour}:${min}:${sec}`; | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment