faressoft faressoft - 2 months ago 5
MySQL Question

How to put the current datetime in MySQL using PHP

How to put the current datetime in MySQL using PHP?

The result should be:

mysql_query("INSERT INTO users (r_date) VALUES ('the current datetime')");


The type of
r_date
is
datetime
.

Answer

If your field is a DATE or DATETIME, NOW() will work:

INSERT INTO users (r_date) VALUES (NOW());");
Comments