gettime() - 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)
+--- Thread: gettime() (
/showthread.php?tid=481507)
gettime() -
x96664 - 16.12.2013
I use to get the current time, using gettime() function and save the unix timestamp into my server database, you can check
my previous thread. However gettime() uses UTC, meanwhile mine is UTC+2 and it won't show the proper time for anybody away from UTC. So should I use another function like NOW() or something else ?
This is how the query to save the unix timestamp looks like:
pawn Код:
format(query, sizeof(query), "UPDATE players SET LastLogin = '%i' WHERE Name = '%s' LIMIT 1", gettime(), Name[playerid]);
Edit: Let me note that I tried to replace gettime with NOW and it gave me this error:
pawn Код:
error 017: undefined symbol "NOW"
Re: gettime() -
Krakuski - 16.12.2013
So you want it to print the time the player logged in?
Try this:
pawn Код:
new Hour, Minute, Second; //Top of the function
gettime(Hour, Minute, Second); //Top of the function
format(query, sizeof(query), "UPDATE players SET LastLogin = '%02d:%02d:%02d' WHERE Name = '%s' LIMIT 1",Hour, Minute, Second, Name[playerid]); //Paste this
This is currently untested.
Re: gettime() -
x96664 - 16.12.2013
Quote:
Originally Posted by Krakuski
So you want it to print the time the player logged in?
Try this:
pawn Код:
new Hour, Minute, Second; //Top of the function gettime(Hour, Minute, Second); //Top of the function format(query, sizeof(query), "UPDATE players SET LastLogin = '%02d:%02d:%02d' WHERE Name = '%s' LIMIT 1",Hour, Minute, Second, Name[playerid]); //Paste this
This is currently untested.
|
Nope the problem is that gettime() returns 1387154236 while it has to be 1387161436 for my country - Bulgaria which is UTC+2.
You can read more, about the unix time -
there.
Re: gettime() -
Chenko - 16.12.2013
You can just add two hours to your gettime result by adding 7200
Re: gettime() -
x96664 - 16.12.2013
Quote:
Originally Posted by Chenko
You can just add two hours to your gettime result by adding 7200
|
I already did it, but I have players worldwide, european, asian. And they will see UTC+2.
Re: gettime() -
arakuta - 16.12.2013
Try this:
https://sampforum.blast.hk/showthread.php?tid=263711
Re: gettime() -
Vince - 16.12.2013
If you want to show the time in the player's own timezone then you'll need the GeoIP plugin or some other method to determine the player's country and timezone.