4

I'm using an api from CryptoCompare, here is the link

The response contains a field name published_on,I tried to use moment to convert to an appropriate date time format but it didn't work.

Does someone know the format or how to convert it to a normal datetime format.I'm using javascript

enter image description here

cuongtd
  • 2,862
  • 3
  • 19
  • 37
  • Related: [System Time is 10 Digit , How? [closed\]](https://stackoverflow.com/questions/18604246/system-time-is-10-digit-how) – Ole V.V. Mar 07 '19 at 08:58

2 Answers2

2

This is called Unix time stamp

console.log(+new Date())  // unix time stamp
console.log(new Date(1551929623 * 1000 )) //unix to normal date conversion

On side note: JS time stamp is in miliseconds where as a UNIX time stamps uses seconds. @JaromandaX thanks for info

Code Maniac
  • 37,143
  • 5
  • 39
  • 60
1

This date is Unix time stamp. Since you are using moment, do the following to convert it to the date format

moment.unix(1551929623).format('DD/MM/YYYY')

Please change the format whatever suits you.

Moment documentation link https://momentjs.com/docs/#/parsing/unix-timestamp-milliseconds/

Prakash Kandel
  • 1,043
  • 6
  • 12