jeudi 9 octobre 2014

Unix Timestamp to (int) seconds

Here's what I have done so far:




pawn Code:




new banExpirySTR[11];

new banExpiryINT;



cache_get_field_content(0, "banexpiry", banExpirySTR);

banExpiryINT = strval(banExpirySTR);



printf("Ban Expiry: %d | Current Time: %d | banExpirySTR: %s", banExpiryINT, gettime(), banExpirySTR);

// Output: Ban Expiry: 2014 | Current Time: 1412850718 | banExpirySTR: 2014-10-09 18:53:49





The field name is `banexpiry` with a data type of TIMESTAMP. Now we know gettime() returns an INT in seconds, I want to get that kind of output from the result of a query. First, I got the string equivalent of the result, converted it to int using strval but ended up with the result 2014. How do I convert the TIMESTAMP result into an INT in seconds?



Thanks!




Aucun commentaire:

Enregistrer un commentaire