1

Dynamo dB is storing a date in string format. For example:

1548005663900

How to convert back to original date format after getting date string data from dynamo dB using javascript?

new Date("1548005663900") is working only in the console and it is not working with Javascript code.

benvc
  • 14,448
  • 4
  • 33
  • 54
Arun
  • 479
  • 1
  • 9
  • 22

1 Answers1

1

You should pass the timestamp string you are getting from your database as an integer to new Date(). For example:

const timestamp = '1548005663900';
const dt = new Date(parseInt(timestamp));
console.log(dt);
benvc
  • 14,448
  • 4
  • 33
  • 54