Right now I have this code:
$mysqldate = date(time());
mysql_query("INSERT INTO permissions (date)
VALUES ('$mysqldate')");
I escape before I insert also, but my problem is that the time is getting stored as all 0s. I was wondering what column datatype in mysql would store something like:
1311602030
a unix timestamp, and then would properly allow me to order by most recent dates on a query.
If timestamp column in database is of type INTEGER you can do
mysql_query("INSERT INTO permissions (date) VALUES ('".time()."')");
As integer value you can also do sort operation and convert it via date()
function from PHP back to a readable date/time format.
If timestamp column in database is of type DATETIME you can do
mysql_query("INSERT INTO permissions (date) VALUES ('".date('Y-m-d H:i:s')."')");
or
mysql_query("INSERT INTO permissions (date) VALUES (NOW())");
Try:
mysql_query("INSERT INTO permissions (date) VALUES ('".$mysqldate."')");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With