简体   繁体   中英

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 .

如果您的字段是DATE或DATETIME,则NOW()将起作用:

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

Note that the now() function insert current date of MySQL server. If you need to insert server date you should use php date function

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM