Timestamp to human date - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Timestamp to human date (
/showthread.php?tid=412818)
Timestamp to human date -
gabyk - 03.02.2013
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.
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
}
Can someone will tell me how to do the calculations?
Re: Timestamp to human date -
Gamer_Z - 03.02.2013
By default pawn does not have the required functions, but there is a plugin which will do what you want:
https://sampforum.blast.hk/showthread.php?tid=294054
Re: Timestamp to human date -
gabyk - 08.02.2013
Heh i resolved.. i made a PHP script..