SA-MP Forums Archive
Unix Time - 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: Unix Time (/showthread.php?tid=248200)



Unix Time - Czeladnik - 12.04.2011

Hi, i need Script Modification, which calculated Unix Time.
It's about the time in seconds that has elapsed since 1 January 1970.


AW: Unix Time - Meta - 12.04.2011

https://sampwiki.blast.hk/wiki/Gettime


Re: Unix Time - Czeladnik - 12.04.2011

And how to move from unix time to "Normal"?


AW: Unix Time - Meta - 12.04.2011

write a function to calculate it


Re: Unix Time - Cameltoe - 12.04.2011

pawn Code:
#define TIME_MS 1
#define TIME_S 2
#define TIME_M 3
#define TIME_H 4

stock ReturnTimeSinceTime(Time1, Time2, Method = TIME_S)
{
     if(Method == TIME_MS) return (Time1 - Time2 * 1000);
     else if(Method == TIME_S) return (Time1 - Time2);
     else if(Method == TIME_M) return (Time1 - Time2 / 60);
     else if(Method == TIME_H) return ( (Time1 - Time2 / 60)  / 60);
}
Example :

pawn Code:
new time = gettime();

ReturnTimeSinceTime(time, gettime());



Re: Unix Time - Vince - 12.04.2011

If you use MySQL:

pawn Code:
stock UNIX_TIMESTAMP()
{
    new
        buf;
       
    // Fetching the timestamp
    mysql_query("SELECT UNIX_TIMESTAMP()");
    mysql_store_result();
   
    buf = mysql_fetch_int();
    mysql_free_result();
   
    return buf;
}



Re: Unix Time - Czeladnik - 14.04.2011

Thanks


Re: Unix Time - Czeladnik - 17.04.2011

Y_Less, yes of course, gettime is very fast, but I'm can't use this function. If PAWN to have as many options as php, it would be good, but unfortunately no.


Re: Unix Time - Cameltoe - 19.04.2011

Quote:
Originally Posted by Czeladnik
View Post
Y_Less, yes of course, gettime is very fast, but I'm can't use this function. If PAWN to have as many options as php, it would be good, but unfortunately no.
I find pawn and php pretty similar.


Re: Unix Time - Cameltoe - 19.04.2011

Quote:
Originally Posted by Y_Less
View Post
Then you're doing one or the other wrong!
How come? the statements are completely the same, or i at least find them pretty similar.