Unix Timestamps - 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: Unix Timestamps (
/showthread.php?tid=603691)
Unix Timestamps -
theonethatownz - 26.03.2016
I am using a unix timestamp to save the date of bans. How can I read this for use in my dialog?
Re: Unix Timestamps -
Abagail - 26.03.2016
This include allows you to convert a timestamp into a human readable date format.
Re: Unix Timestamps -
theonethatownz - 26.03.2016
Thanks
Using that include, I get a argument error (1) come up.
pawn Код:
forward ShowBanDialog(playerid);
public ShowBanDialog(playerid)
{
new rows, fields, date[6];
cache_get_data(rows, fields);
if(rows)
{
new timestamp[50],BannedBy[32],BanReason[80],string[300];
cache_get_field_content(0, "Timestamp", timestamp, mysql, 50);
cache_get_field_content(0, "BannedBy",BannedBy,mysql,32);
cache_get_field_content(0, "BanReason",BanReason,mysql,80);
TimestampToDate(timestamp,date[0],date[1],date[2],date[3],date[4],date[5],2);
format(string,sizeof(string),"You have been banned by %s\nReason: %s\nAt: %d/%d/%d %d:%d\nIf you think that this is a mistake or deserve an other chance,apply on forums",BannedBy,BanReason,date[2],date[1],date[0],date[3],date[4]);
ShowPlayerDialog(playerid,BannedDialog,DIALOG_STYLE_MSGBOX,"Banned",string,"Close","");
}
return 1;
}
Thats the line
pawn Код:
TimestampToDate(timestamp,date[0],date[1],date[2],date[3],date[4],date[5],2);
Re: Unix Timestamps -
Mencent - 26.03.2016
Hi!
Timestamp shouldn't be a string. You don't have to change all because you can do this:
PHP код:
TimestampToDate(timestamp,date[0],date[1],date[2],date[3],date[4],date[5],2);
to
PHP код:
TimestampToDate(strval(timestamp),date[0],date[1],date[2],date[3],date[4],date[5],2);
Re: Unix Timestamps -
theonethatownz - 26.03.2016
Thanks!
Re: Unix Timestamps -
czerwony03 - 26.03.2016
You can easily add to SELECT query:
PHP код:
SELECT *, FROM_UNIXTIME(`Timestamp`) AS `date` FROM blablabbla...
And than,
PHP код:
cache_get_field_content(0, "date", readable_timestamp, mysql, 50);