would appreciate any help on this. I am using this API and the data is returned in JSON format. However, the date/time is returned as a value similar to this: dt: 1645068034
How can I convert this to a readable format in my react project?
2 Answers
I found the solution for this in this site Cloudhadoop-React-timestamp. Feel free to refer to this for additional information.
The date-time format that you are getting from the API mentioned in your question is in the Unix format.

let currentTimestamp = Date.now()
console.log(currentTimestamp); // get current timestamp
let date = new Intl.DateTimeFormat('en-US', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' }).format(currentTimestamp)
console.log(date)
Intl.DateTimeFormat allows you to specify exactly which format would you want the Unix date in your application to be converted to.docs
You can also specify if you want to convert the Unix date to just time or date as well
//Just Date
let currentTimestamp = Date.now()
let date = new Intl.DateTimeFormat('en-US', { year: 'numeric', month: '2-digit', day: '2-digit' }).format(currentTimestamp) // 01/11/2021
console.log(date)
//Just Time
let currentTimestamp = Date.now()
let date = new Intl.DateTimeFormat('en-US', { hour: '2-digit', minute: '2-digit', second: '2-digit' }).format(currentTimestamp)//9:27:16 PM
console.log(date)