Created
November 28, 2023 02:55
-
-
Save terwer/b5799314b8af293544b26e79cb7bd365 to your computer and use it in GitHub Desktop.
js timestamp to date
This file contains hidden or 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 convertTimestampToDateString = (timestamp) => { | |
const months = [ | |
"January", | |
"February", | |
"March", | |
"April", | |
"May", | |
"June", | |
"July", | |
"August", | |
"September", | |
"October", | |
"November", | |
"December", | |
] | |
const date = new Date(parseInt(timestamp)) | |
const monthIndex = date.getMonth() | |
const month = months[monthIndex] | |
const day = date.getDate() | |
const year = date.getFullYear() | |
return `${month} ${day}, ${year}` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment