gettime()
#1

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"
Reply
#2

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

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

You can just add two hours to your gettime result by adding 7200
Reply
#5

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

Try this: https://sampforum.blast.hk/showthread.php?tid=263711
Reply
#7

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


Forum Jump:


Users browsing this thread: 1 Guest(s)