Converting 10 Digit Timestamp To Date

1 min read

Converting/reading 10 digit timestamp might seem confusing. I found this value in a field of a JSON response from an API where I was expecting a date. At the first, I couldn't figure out how to convert it to date for UI. After some research I found that the 10-digit timestamps represent the number of seconds.

Anyway, history lesson finished. How do you convert that to something useful in Javascript?

Timestamp
const ts = 1504095567183

Native#

new Date(ts)

Moment.js#

moment(ts)

Day.js#

dayjs.unix(ts)
Discuss on Twitter ⟶
onur dot suyalcinkaya at gmail dot com