Skip to content

Instantly share code, notes, and snippets.

@terwer
Created November 28, 2023 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terwer/b5799314b8af293544b26e79cb7bd365 to your computer and use it in GitHub Desktop.
Save terwer/b5799314b8af293544b26e79cb7bd365 to your computer and use it in GitHub Desktop.
js timestamp to date
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