Unix Time
#1

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

https://sampwiki.blast.hk/wiki/Gettime
Reply
#3

And how to move from unix time to "Normal"?
Reply
#4

write a function to calculate it
Reply
#5

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());
Reply
#6

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;
}
Reply
#7

Thanks
Reply
#8

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)