1

I am unable to understand the below date format which i am getting from API response. Can you please help me to understand this format ?

data = "1612179241760"

And how we can get the same date format when we pass the current date through moment and it should convert into same above format ?

Vickram
  • 187
  • 11
  • Would passing that into a new date object do what you want? `new Date(Number(data))` (note the string needs to be parsed as a number) – evolutionxbox Feb 01 '21 at 11:51
  • `const date = new Date(+data); const timeStamp = date.getTime();` - no need for moment - [RTM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) – mplungjan Feb 01 '21 at 11:55
  • "*Can you please help me to understand this format?*" That is the number of milliseconds between January 1, 1970, 00:00:00 UTC and the date you are considering. In particular `1612179241760` corresponds to `Mon Feb 01 2021 11:34:01 UTC` – secan Feb 01 '21 at 12:03

0 Answers0