[HELP] convert unix timestamp to d,m,y format -
Luca12 - 10.10.2014
Hello is there a way when I showing in text when is player last logged in to show in format 10/10/2014. Know I have in mysql format like 2014-10-10 so is there a way to convert this in format above this text and to show that format to admins when they check offline player last activity ? Thanks
Re: [HELP] convert unix timestamp to d,m,y format -
Malicious - 10.10.2014
Are you meaning in game? (scriptwise)?
Re: [HELP] convert unix timestamp to d,m,y format -
Luca12 - 10.10.2014
yes I want to convert unixtimestamp from format 2014-10-10 to format 10/10/2014. Thanks
Re: [HELP] convert unix timestamp to d,m,y format -
Malicious - 10.10.2014
Could you show me the code where you have the date being set?
Re: [HELP] convert unix timestamp to d,m,y format -
Luca12 - 10.10.2014
if you know anything about mysql then you should know that is timestamp automatic set date and time into player column it's not in script. Anyway thanks for replying.
Re: [HELP] convert unix timestamp to d,m,y format -
Threshold - 10.10.2014
https://sampwiki.blast.hk/wiki/Getdate
Quote:
Originally Posted by SA-MP Wiki
pawn Код:
new Year, Month, Day; getdate(Year, Month, Day); printf("%02d/%02d/%d", Day, Month, Year);
|
Re: [HELP] convert unix timestamp to d,m,y format -
Malicious - 10.10.2014
Sorry, have you tried this?
http://www.w3schools.com/sql/func_date_format.asp
Re: [HELP] convert unix timestamp to d,m,y format -
Luca12 - 10.10.2014
So I was put under onplayerdisconnect
pawn Код:
new str[128],Year,Month,Day;
getdate(Year,Month,Day);
format(str,128,"%d/%d/%d",Day,Month,Year);
and then
pawn Код:
mysql_format(mysql,query,sizeof(query),"UPDATE `users` SET `LastActivity` = %s WHERE `ID` = '%d'",str,PlayerInfo[playerid][ID]);
mysql_tquery(mysql,query,"","");
LastActivity column is set to varchar which is string
and when I enter in server and disconnect the result in player column LastActivity was 0.000496524329692154
Re: [HELP] convert unix timestamp to d,m,y format -
Eth - 10.10.2014
then you can do something like :
pawn Код:
mysql_format(mysql,query,sizeof(query),"UPDATE `users` SET `LastActivityDay` = %d,`LastActivityMonth` = '%d',
`LastActivityYear`='%d' WHERE `ID` = '%d'",Day,Month,Year,PlayerInfo[playerid][ID]);
mysql_tquery(mysql,query,"","");
you have to add LastActivityYear,LastActivityDay,LastActivityMonth to the mysql and when you load it:
PlayerInfo[playerid][LastActivityYear],PlayerInfo[playerid][LastActivityDay],
PlayerInfo[playerid][LastActivityMonth] and you have to add LastActivityYear,LastActivityMonth,LastActivityDay to the player info enums
so example of loading:
pawn Код:
new str[120];
format(str,120,"Your last activity: %d/%d/%d",PlayerInfo[playerid][LastActivityDay],PlayerInfo[playerid][LastActivityMonth],PlayerInfo[playerid][LastActivityYear]);
SendClientMessage(playerid,-1,str);
Re: [HELP] convert unix timestamp to d,m,y format -
Luca12 - 13.10.2014
anyone? thanks