03.02.2013, 08:54
Hi, i want to make a PAWN converter timestamp to human date, i have a java function from a site... but i don't know how to make calculations like in java functions.
Can someone will tell me how to do the calculations?
PHP код:
function EpochToHuman() {
var e = document.ef.TimeStamp.value;
if (e.charAt(e.length - 1) == "L") {
e = e.slice(0, -1)
}
e = e * 1;
var t = e;
var n = "";
var r = 0;
if (e >= 1e14) {
n += "<b>Assuming that this timestamp is in microseconds (1/1,000,000 second):</b><br/>";
t = Math.round(e / 1e6);
e = Math.round(e / 1e3)
} else if (e >= 1e11) {
n += "<b>Assuming that this timestamp is in milliseconds:</b><br/>";
t = Math.round(e / 1e3)
} else {
if (e > 1e10) r = 1;
e = e * 1e3
}
var i = new Date(e);
if (isValidDate(i)) {
var s = i.toLocaleString();
var o = s.search(/GMT/i);
if (o > 0) {
s = s.substring(0, o)
}
n += "<b>GMT</b>: " + i.toGMTString();
n += '<br/><b>Your time zone</b>: <span title="' + i.toLocaleString() + '">' + s + '</span> <a title="convert to other time zones" href="http://www.epochconverter.com/epoch/timezones.php?epoch=' + t + '">' + localTimezone(i) + "</a>";
if (r) n += "<br/>This conversion uses your timestamp in seconds. Remove the last 3 digits if you are trying to convert milliseconds."
} else {
n += "Sorry, I can't parse this date.<br/>Check your timestamp, strip letters and punctuation marks."
}
n += '<hr class="lefthr">';
document.getElementById("result1").innerHTML = n
}