Converting a 13 digit Unix timestamp to DateTime with Javascript
NickName:KawynS Ask DateTime:2019-07-18T18:24:47

Converting a 13 digit Unix timestamp to DateTime with Javascript

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

Answers
shrys 2019-07-18T10:33:05

You can pass timestamp into Date:\n\n\r\n\r\nvar unixts = 1563398686957;\r\nvar date = new Date(unixts);\r\n\r\nvar fdate = date.getFullYear() + '/' + (\"0\" + (date.getMonth() + 1)).slice(-2) + '/' + (\"0\" + date.getDate()).slice(-2);\r\nconsole.log(fdate);",


More about “Converting a 13 digit Unix timestamp to DateTime with Javascript” related questions

Converting a 13 digit Unix timestamp to DateTime with Javascript

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 digit...

Show Detail

Netezza - How to convert timestamp/datetime to 13-digit UNIX time millis?

I have read some reference about Netezza, but I cannot figure out how to convert timestamp/datetime value to 13-digit UNIX time millis. Any suggestion or ideas?

Show Detail

How to convert 10 digit timestamp to 13 digit timestamp?

In Python 2 how to convert 10 digit timestamp to 13 digit timestamp? Input: today = datetime.now() yesterday = datetime.now() - timedelta(days=1) today_unixtime = int((mod_time.mktime(today.timet...

Show Detail

Converting Unix 13-digits to datetime/timestamp format with pandas

I have a pandas data frame containing 13-digit/milliseconds data like below, which I am trying to convert to legible date and timestamp format using .datetime() or 'pd.Timestamp(), both of which se...

Show Detail

How to convert a 13 digit Unix Timestamp to Date and time?

I have this 13 digit timestamp 1443852054000 that i want to convert to date and time but dont succeed. I have tried this codes: echo date('Y-m-d h:i:s',$item-&gt;timestamp); doesnt work for me and

Show Detail

How to convert a 13 digit Unix Timestamp to Date and time?

I have this 13 digit timestamp 1443852054000 that i want to convert to date and time but dont succeed. I have tried this codes: echo date('Y-m-d h:i:s',$item-&gt;timestamp); doesnt work for me and

Show Detail

How to convert a 13 digit Unix Timestamp to Date and time?

I have this 13 digit timestamp 1443852054000 that i want to convert to date and time but dont succeed. I have tried this codes: echo date('Y-m-d h:i:s',$item-&gt;timestamp); doesnt work for me and

Show Detail

19 Digit Timestamp Conversion

I have a set of 19 digit timestamps, stamp, that I cannot figure out how to convert to a datetime format. For comparison, stamp corresponds to dt. In the following code, dt has been converted to

Show Detail

Converting Between HubSpot Unix Timestamp and SQL DateTime

I am getting and posting data between HubSpot and my database. HubSpot hold DateTime as UNIX Milliseconds and I am having trouble getting the same value when converting too and from. (I want to ...

Show Detail

converting 13-digit unixtime in ms to timestamp in python

I want to convert 13-digit Unix-time in milliseconds to the timestamp : "1523126888080"==>> %Y-%m-%d %H:%M:%S I have tried the following code from this link, But I think this is for 10-digit Unix...

Show Detail