Unix Timestamps
#1

I am using a unix timestamp to save the date of bans. How can I read this for use in my dialog?
Reply
#2

This include allows you to convert a timestamp into a human readable date format.
Reply
#3

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

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); 
Reply
#5

Thanks!
Reply
#6

You can easily add to SELECT query:
PHP код:
SELECT *, FROM_UNIXTIME(`Timestamp`) AS `dateFROM blablabbla... 
And than,
PHP код:
cache_get_field_content(0"date"readable_timestampmysql50); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)