Timestamp being weird - 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: Timestamp being weird (
/showthread.php?tid=523169)
Timestamp being weird -
sammp - 01.07.2014
pawn Код:
new Query[128],
Timestamp,
Day,
Month,
Year,
Hour,
Minute,
Second;
TimestampToDate(Timestamp, Year, Month, Day, Hour, Minute, Second, GMT_H, GMT_M);
mysql_format(szCurrent, Query, sizeof(Query), "UPDATE `accounts` SET `LastOnline` = '%i-%i-%i at %i:%i:%i' WHERE `Username` = '%e' LIMIT 1", Day, Month, Year, Hour, Minute, Second, Name[playerid]);
mysql_tquery(szCurrent, Query, "");
What's wrong with that? I'm having troubles
Basically, the trouble is that the query isnt sending the correct information:
Re: Timestamp being weird -
BroZeus - 01.07.2014
pawn Код:
new Query[128],
Timestamp,
Day,
Month,
Year,
Hour,
Minute,
Second;
Timestamp = gettime(); // note this line
TimestampToDate(Timestamp, Year, Month, Day, Hour, Minute, Second, GMT_H, GMT_M);
mysql_format(szCurrent, Query, sizeof(Query), "UPDATE `accounts` SET `LastOnline` = '%i-%i-%i at %i:%i:%i' WHERE `Username` = '%e' LIMIT 1", Day, Month, Year, Hour, Minute, Second, Name[playerid]);
mysql_tquery(szCurrent, Query, "");
Re: Timestamp being weird -
Vince - 01.07.2014
What is the point of using timestamps if you're going to save it in human readable format anyway? A format which - by the way - isn't recognized by MySQL, which makes it far more difficult to sort, group and search.
http://dev.mysql.com/doc/refman/5.5/..._utc-timestamp
Re: Timestamp being weird -
sammp - 01.07.2014
Thanks for the reply, Vince and BroZeus.
Thanks for helping me, BroZeus.
Thanks for pointing that out Vince, I didn't know about it. I'm going to do this so it can be searched:
LastOnlineDay
LastOnlineMonth
LastOnlineYear
LastOnlineHour
LastOnlineMinute
LastOnlineSecond