简体   繁体   中英

How to convert epoch timestamp to current timestamp?

How will I convert epoch timestamp millisecond to current time stamp milliseconds.

My Try:

 var time = (resp.timestamp * 1000) + 1980000000;

resp.timestamp -> epoch timestamp

I have tried adding 5hrs 30 minutes(converted to miliseconds) to the epoch timestamp but I am unable to get current time.

UPDATED try this:

 function ToLocalDate () {

        var n = Date.now()
        var d = new Date(n);
        console.log(d);
        console.log(d.getDate());
        console.log(d.getMonth());
        console.log(d.getFullYear());
        console.log(d.getHours());
        console.log(d.getMinutes());
        console.log(d.getSeconds());
       }
    ToLocalDate ();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM