关于时间戳(MYSQL)的问题
我想知道什么更快。
我需要比较现在和表中日期时间之间的秒数。 我的专栏类型是时间戳,这是最好的方法吗?因为我想知道时间戳和 int 之间有什么区别?或者我应该使用日期时间?
因为我想要的就是这样的:1314288065 所以我现在就输入时间 - 1314288065,它会给我秒数。
谢谢你祝你
有美好的一天
I'm wondering what is faster.
I need to compare the number of seconds between now and a datetime in my table.
The type of my column is Timestamp, is it the best way? Cause im wondering what's the difference between timestamp and an int? Or should I use datetime?
cause all I want is something like that: 1314288065
so I would do the time now - 1314288065 and it would give me the number of seconds.
Thank you
Have a nice day
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您要存储时间,请将其存储为日期时间。
现在你只需要几秒钟的差异,但稍后你会想在几周/几天/几小时/...内很好地格式化差异,然后你将开始重新发明轮子。您也不将字符串/整数存储为 BLOB,是吗?
If you're storing time, store it as a datetime.
Right now you'll only need the difference in seconds, but later you'll want to format the difference nicely in weeks/days/hours/... and you'll start reinventing the wheel. You're not storing strings/ints as BLOBs either, are you?
几个月后,我终于使用了 int,因为使用它来处理时区更容易,而且它已经是我想要的格式。但是这个项目中的所有其他日期都是日期时间。
谢谢大家。
Months after, finaly I use int cause it's more easy to work with this for time zones and it's already in the format I want.But all the other dates in this project are in datetime.
Thank you all.