28.11.2013, 01:07
Hey guys, I have some problems with timestamps:
I use to send an update query with unix timestamp, when player logs in to his account and show a message with the last time on, the message looks like:
Welcome back, Wizzy951! Your last login was on 2013-11-28 03:22:15.
I would want the message look like:
Welcome blabla on November 28, 2013 at 03:22:15, Also if the last login was on the same day to show Today, at 03:22:15
And there is my code:
The second problem is related with the database structure and I'm not even sure if I have to ask there, but still I believe someone could help me: I had wanted to use timestamp also when player registers so I added a new line called ReggedOn with type: timestamp without setting anything else and I received the following error:
#1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
Thanks in advance!
Edit: Rep only to the useful replies!
I use to send an update query with unix timestamp, when player logs in to his account and show a message with the last time on, the message looks like:
Welcome back, Wizzy951! Your last login was on 2013-11-28 03:22:15.
I would want the message look like:
Welcome blabla on November 28, 2013 at 03:22:15, Also if the last login was on the same day to show Today, at 03:22:15
And there is my code:
pawn Код:
#define pLastLoginx 1 //it's used for the update query, I got this from a gamemode from the forums, I don't really remember whose it was
pLastLogin[130]//this stays within the enumerator
//on loading player stats
cache_get_field_content(0, "LastLogin", tmp), strmid(PInfo[playerid][pLastLogin], tmp, 0, 255, 255);
Update(playerid, pLastLoginx);
format(string, sizeof(string), "Welcome back, %s! Your last login was on %s", rName(playerid), PInfo[playerid][pLastLogin]);
SendClientMessage(playerid, -1, string);
//the update function which I got from the gamemode I mentioned before
public Update(playerid, type)
{
if(IsPlayerConnected(playerid))
{
new query[256];
{
switch(type)
{
case pLastLoginx:
{
format(query, sizeof(query), "UPDATE players SET LastLogin = NOW() WHERE Name = '%s' LIMIT 0,1", rName(playerid));
mysql_query(Db, query);
}
}
}
}
}
#1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
Thanks in advance!
Edit: Rep only to the useful replies!