简体   繁体   English

mysql datetime时间戳时间之间的差异

[英]Difference between mysql datetime timestamp time

I want to get the current time when a login attempt is processed. 我想获取处理登录尝试的当前时间。 I want to get the time retrieved in probably date and hour/min/sec. 我想获取可能以日期和小时/分钟/秒表示的时间。

I have a database with a field called last_attempt , which holds the date and time of the last login attempt. 我有一个名为last_attempt的字段的数据库,其中包含上次登录尝试的日期和时间。

Which of the types Datetime , Timestamp , Time or others should I use for the field? 我应该为该字段使用哪种类型的DatetimeTimestampTime或其他类型? And also what method in PHP should I use? 我还应该在PHP中使用哪种方法?

PHP time() is all you need. 您只需要PHP time()。 It returns the current time posted at the server in seconds from epoch january. 它返回从一月纪元开始以秒为单位的服务器上发布的当前时间。 (You'll store the result as a unsigned number most likely.) (您很有可能将结果存储为无符号数字。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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