SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 12/04/2011, 06:36 PM   #1
Czeladnik
Little Clucker
 
Join Date: Mar 2011
Posts: 28
Reputation: 0
Default Unix Time

Hi, i need Script Modification, which calculated Unix Time.
It's about the time in seconds that has elapsed since 1 January 1970.
Czeladnik is offline  
Old 12/04/2011, 06:40 PM   #2
Meta
Gangsta
 
Meta's Avatar
 
Join Date: Feb 2010
Location: Germany
Posts: 646
Reputation: 44
Default AW: Unix Time

http://wiki.sa-mp.com/wiki/Gettime
Meta is offline  
Old 12/04/2011, 06:43 PM   #3
Czeladnik
Little Clucker
 
Join Date: Mar 2011
Posts: 28
Reputation: 0
Default Re: Unix Time

And how to move from unix time to "Normal"?
Czeladnik is offline  
Old 12/04/2011, 07:33 PM   #4
Meta
Gangsta
 
Meta's Avatar
 
Join Date: Feb 2010
Location: Germany
Posts: 646
Reputation: 44
Default AW: Unix Time

write a function to calculate it
Meta is offline  
Old 12/04/2011, 07:51 PM   #5
Cameltoe
High-roller
 
Cameltoe's Avatar
 
Join Date: Apr 2010
Location: Norway
Posts: 1,782
Reputation: 24
Default Re: Unix Time

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());
__________________

Quote:
Originally Posted by Cameltoe View Post
Share the progress so others who are looking for the same also find's their answer.
Quote:
Originally Posted by teomakedonija View Post
ahaha i don't want
Rep++;
Cameltoe is offline  
Old 12/04/2011, 08:25 PM   #6
Vince
Godfather
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 6,519
Reputation: 1695
Default Re: Unix Time

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;
}
__________________
I will rarely post a ready made solution in your thread, but rather I try to make you realize your own mistakes so you can fix them yourself.
The average intellect of the average SA-MP forums user.
Vince is offline  
Old 14/04/2011, 09:22 AM   #7
Czeladnik
Little Clucker
 
Join Date: Mar 2011
Posts: 28
Reputation: 0
Default Re: Unix Time

Thanks
Czeladnik is offline  
Old 14/04/2011, 09:56 AM   #8
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 17,597
Reputation: 2442
Default Re: Unix Time

What the heck? "gettime" returns the unix timestamp vastly faster than MySQL possibly could!
Y_Less is offline  
Old 17/04/2011, 08:44 AM   #9
Czeladnik
Little Clucker
 
Join Date: Mar 2011
Posts: 28
Reputation: 0
Default Re: Unix Time

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.
Czeladnik is offline  
Old 19/04/2011, 04:58 PM   #10
Cameltoe
High-roller
 
Cameltoe's Avatar
 
Join Date: Apr 2010
Location: Norway
Posts: 1,782
Reputation: 24
Default Re: Unix Time

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

Quote:
Originally Posted by Cameltoe View Post
Share the progress so others who are looking for the same also find's their answer.
Quote:
Originally Posted by teomakedonija View Post
ahaha i don't want
Rep++;
Cameltoe is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
lvrcr time stand time start on 12:00 go to 12:59 and then go back to 12:00 ownboy Help Archive 2 24/02/2010 07:53 PM
In game time not match real time speedy199 Help Archive 3 01/04/2009 10:41 AM


All times are GMT. The time now is 03:03 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.