I'm trying to convert this 13 digit Unix timestamp (1563398686957) to YYYYMMDD format using Javascript. How can I do this?
I have divided the 1563398686957/1000 and tried to get the first 10 digits but converting from Number to String and back gives me an error and is not there right way to do it if I am looping for many timestamps.
var newCreateDate = 1563398686957 / 1000;
var newTimestamp = Array();
for (let i = 0; i < newCreateDate.length; i++) {
temp_timestamp = String(newCreateDate[i].slice(0, 9));
newTimestamp.push(Number(temp_timestamp));
}
Copyright Notice:Content Author:「KawynS」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/57092388/converting-a-13-digit-unix-timestamp-to-datetime-with-javascript