Timestamp to string.
#7

pawn Код:
// top
new DB:DateTimeDB;
pawn Код:
// OnFilterScriptInit / OnGameModeInit
DateTimeDB = db_open("DateTimeDB.db");
pawn Код:
// OnFilterScriptExit / OnGameModeExit
db_close(DateTimeDB);
pawn Код:
GetTimeAndDate(timestamp, dest[], s_size = sizeof(dest))
{
    new str[80];
    format(str,sizeof(str),"SELECT datetime(%d, 'unixepoch', 'localtime');",timestamp);
    new DBResult:result = db_query(DateTimeDB,str);
    db_get_field(result, 0, dest, s_size);
    db_free_result(result);
}
pawn Код:
// usage
new string[20], time = gettime();
GetTimeAndDate(time, string);
print(string); // will print year-month-day hour:min:second, you can use sscanf for split and format to day/month/year - hour/min/second
if you are using sqlite in GM you can replace DateTimeDB to your own
Reply


Messages In This Thread
Timestamp to string. - by Baltimore - 15.01.2015, 17:41
Re: Timestamp to string. - by RedCounty - 15.01.2015, 17:44
Re : Timestamp to string. - by Baltimore - 15.01.2015, 17:56
Re: Timestamp to string. - by dominik523 - 15.01.2015, 18:10
Re : Timestamp to string. - by Baltimore - 15.01.2015, 18:17
Re: Timestamp to string. - by dominik523 - 15.01.2015, 18:31
Re: Timestamp to string. - by Jefff - 16.01.2015, 16:32
Re: Timestamp to string. - by xVIP3Rx - 16.01.2015, 16:37
Re : Timestamp to string. - by Baltimore - 16.01.2015, 23:36

Forum Jump:


Users browsing this thread: 1 Guest(s)