Inverse function of mktime()
#1

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
Reply
#2

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.
Reply
#3

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
Reply
#4

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.
Reply
#5

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)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)