且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

以日期时间格式mySQL插入当前日期

更新时间:2023-01-29 07:57:06

如果要存储当前时间,请使用MYSQL的函数.

If you're looking to store the current time just use MYSQL's functions.

mysql_query("INSERT INTO `table` (`dateposted`) VALUES (now())");

如果需要使用PHP进行格式化,请格式化Y-m-d H:i:s,请尝试

If you need to use PHP to do it, the format it Y-m-d H:i:s so try

$date = date('Y-m-d H:i:s');
mysql_query("INSERT INTO `table` (`dateposted`) VALUES ('$date')");