Timestamp being weird
#1

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:
pawn Код:
-1-1-1970 at 0:1:0
Reply
#2

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, "");
Reply
#3

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)