var systs=1743674494161 // unix timestamp //var ts = 1565605570; var diffts = (new Date()) - systs; // convert unix timestamp to milliseconds //var ts_ms = ts * 1000; // initialize new Date object function sysTime(diffts){ var localts = (new Date())-diffts; var date_ob = new Date(localts); // year as 4 digits (YYYY) var year = date_ob.getFullYear(); // month as 2 digits (MM) var month = ("0" + (date_ob.getMonth() + 1)).slice(-2); // date as 2 digits (DD) var date = ("0" + date_ob.getDate()).slice(-2); // hours as 2 digits (hh) var hours = ("0" + date_ob.getHours()).slice(-2); // minutes as 2 digits (mm) var minutes = ("0" + date_ob.getMinutes()).slice(-2); // seconds as 2 digits (ss) var seconds = ("0" + date_ob.getSeconds()).slice(-2); // YYYY-MM-DD var fulldate = "" + year + "-" + month + "-" + date; // hh:mm:ss var fulltime = "" + hours + ":" + minutes+ ":" +seconds; // YYYY-MM-DD hh:mm:ss var fulldatetime = fulldate + " " + fulltime; return fulltime; } var intervalID = setInterval(function() { //document.title = sysTime(diffts); document.getElementById("clockts").innerHTML = "Linux Time: " +sysTime(diffts); }, 1000);