Inverse function of mktime() - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Inverse function of mktime() (
/showthread.php?tid=227545)
Inverse function of mktime() -
Level147 - 17.02.2011
Hey guys,
I'm looking for the inverse function of mktime, what the headline already tells.
Everywhere I find the code of the function mktime to create a timestamp but nowhere there is the inverse function of it (I think it is getTime() in C++).
Has anybody the code of this function and at the best written in Pawn?
I would enjoy a rapid answer.
Regards,
Level147
Re: Inverse function of mktime() -
Calgon - 17.02.2011
gettime() without any arguments will return the current Unix Timestamp.
(to my knowledge) There are no functions that will return the time from a timestamp in PAWN that are natively implemented.
Re: Inverse function of mktime() -
Level147 - 17.02.2011
I've heard from a function in C called getTime() that returns the formated time from a timestamp.
I know there isn't any native function in pawn, but maybe someone has got a function for it
Re: Inverse function of mktime() -
Calgon - 17.02.2011
The definition of inverse is reversed/turned backward(s). You're looking for a PAWN version of mktime (it seems, you're hardly making sense).
There's a PAWN version of mktime in
uf.inc, if that's what you're looking for.
Re: Inverse function of mktime() -
Blacklite - 17.02.2011
If you're using mysql, you can do it like this:
pawn Код:
stock getdate(date[], timestamp = 0) {
if (timestamp > 0) {
new query[64];
format("SELECT FROM_UNIXTIME(%d, '%%Y %%D %%M %%h:%%i:%%s %%x') AS thedate", timestamp);
mysql_query(query);
} else {
mysql_query("SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(), '%Y %D %M %h:%i:%s %x') AS thedate");
}
mysql_fetch_field("thedate", date);
mysql_free_result();
}
(code not tested, but should be pretty close)