我有一个MySQL查询:
$SQLquery = "INSERT INTO `experimental`.`comments` (`comment_id`, `comment_dt`)
VALUES (NULL, CURRENT_TIMESTAMP);";当我在MySQL行的comment_dt数据库中使用PHP执行这一行时,会出现(本地时间和日期)。有人知道如何在我的数据库中显示本地和时间日期的服务器吗?
发布于 2012-04-03 01:33:37
最好的方法是使comment_dt列DATETIME类型并设置默认值CURRENT_TIMESTAMP。不需要通过insert查询手动插入。
每次插入新行时,您的comment_dt都会使用服务器日期时间自动更新。
ALTER TABLE comments ADD comment_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP 发布于 2012-04-03 01:23:00
$SQLquery = "INSERT INTO `experimental`.`comments` (`comment_id`, `comment_dt`) VALUES (NULL, CURRENT_TIMESTAMP());";使用MySQL服务器函数CURRENT_TIMESTAMP()
https://stackoverflow.com/questions/9985951
复制相似问题