php - MySQL : using datetime or timestamp for logged in history

标签 php mysql

我正在做一个应用程序,我必须存储员工的登录和注销时间,现在这就是逻辑

1-如果不保存当前时间,我将查询登录字段以检查今天是否存在任何值(因此我必须查询和操作该值)

2-对于注销,每次注销都是最后一次注销,因此我必须跟踪日期以确保为今天的日期保存最后一个值

3-在管理面板中,我必须添加使用 jquery 日期选择器搜索登录/注销历史记录的功能,

所以根据这个标准,你们可以建议我应该选择哪一个吗,我浏览了官方文档,但无法得到这一点

最佳答案

它们都适合您的要求。 http://dev.mysql.com/doc/refman/5.7/en/datetime.html

The DATETIME type is used for values that contain both date and time parts. 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 is used for values that contain both date and time parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.

一些区别:

MySQL converts TIMESTAMP values from the current time zone to UTC for storage, and back from UTC to the current time zone for retrieval. (This does not occur for other types such as DATETIME.)

关于php - MySQL : using datetime or timestamp for logged in history,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34378880/

相关文章:

php - 如何用逗号添加值?

php - TestLink - 数据库访问错误 - debug_print_backtrace() 输出启动 (CWE-200)

mysql - Solr_version_字段错误

php - 如何自动化数据收集而不卡住 10%

php - 通过电子邮件更新 Mysql 表

php - 访问 ESI 标记内的 php 变量

PHP 准备语句 Foreach 循环

php - 在 laravel 5.4 中检索软删除的用户帖子

mysql - memsql多表删除,可以吗?

php - 绑定(bind)变量的数量与php和android中的prepared语句中的字段数不匹配