28.09.2013, 19:41
I give you a tip, when you save the timestamps as unbantime and the bantime about mysql than get the timestamps about MySQL to instead of the function gettime.
Use the SQL-Command NOW() to return the actual Date and Time and change the colume datatyp from int to timestamp. You can add to this time hours , minutes , days and so on to with DATE_ADD.
A example Query from my own Ban-system
SELECT -Query to load the data
INSERT-Query
to check if the Player is now unbanned or not.
EntbanDatum = Unbandate.
Datum = Date
Grund = Reason
Use the SQL-Command NOW() to return the actual Date and Time and change the colume datatyp from int to timestamp. You can add to this time hours , minutes , days and so on to with DATE_ADD.
A example Query from my own Ban-system
SELECT -Query to load the data
Code:
"SELECT `Admin`, `Grund`, DATE_FORMAT(`Datum`, 'Am %%d.%%m.%%Y um %%T Uhr') AS `BDatum`, DATE_FORMAT (`EntbanDatum`, '%%d.%%m.%%Y um %%H:%%i:%%s Uhr') AS `BEntbanDatum` ,`IP` FROM `bans` WHERE `Name` = '%e' AND `EntbanDatum` > NOW() LIMIT 0,1;"
PHP Code:
"INSERT INTO `bans` (`Name`, `Admin`, `Grund`, `Datum`, `EntbanDatum`, `IP`, `GPCI`) VALUES ('%s', '%s', '%s', NOW(), DATE_ADD(NOW(), INTERVAL %d DAY), '%s', '%s');"
Code:
SELECT `EntbanDatum` FROM `bans` WHERE `EntbanDatum` <= NOW();
Datum = Date
Grund = Reason