16.01.2015, 16:32
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
