php:数据库字段的current_timestamp?

标签 php timestamp

我正在尝试添加一个名为“lastLogin”的数据库字段,每次有人登录时都会填充该字段。 尝试添加字段时出错:

#1294 - Invalid ON UPDATE clause for 'lastLogin' column 

我不确定出了什么问题 - 我在 phpmyadmin 中有以下设置:

field: lastlogin
type: date
standard: none
attribute: on update CURRENT_TIMESTAMP

知道哪里出了问题吗?

谢谢

最佳答案

您的字段类型设置为日期应该是时间戳日期时间

The DATETIME type is used when you need values that contain both date and time information. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.

The TIMESTAMP data type has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC. It has varying properties, depending on the MySQL version and the SQL mode the server is running in. These properties are described later in this section.

关于php:数据库字段的current_timestamp?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5683670/

相关文章:

php - 使用 PHP 获取 Facebook 元标记

PHP 提前关闭连接。如果完成任何输出,脚本将挂起

PHP str_replace 函数

php - pdo 插入语句使用日期时间错误

javascript - 这个时间戳是什么格式,我怎样才能把它格式化成它自己的时间

java - Java中的时间测量开销

php - 使用 HTTPS 获取国家和城市

php - 如何创建类似 youtube 的视频预览?

python - 如何将 pandas 时间戳添加到 read_csv 后的数据帧中

linux - 如何在 Curl 字符串中使用公历时间戳