将时间跨度存储在MySQL数据库中的最佳方法? [英] Best way to store span on time in a MySQL database?

查看:60
本文介绍了将时间跨度存储在MySQL数据库中的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在mysql数据库中存储某些内容的时间,例如某时间所花费的时间,例如2小时,5分钟,10秒.精度低至秒是首选,但不是必需的.最好的方法是什么?

I'd like to store an amount of time for something in a mysql database,for the length of time something took, such as 2 hours, 5 minutes, 10 seconds. accuracy down to the second is preferred, but not required. What's the best way to go about doing this?

推荐答案

MySQL

A MySQL TIME type can store time spans from '-838:59:59' to '838:59:59' - if that's within your required range, and it would be useful to have MySQL natively present these spans in HH:MM:SS form, then use that.

否则,我将使用整数类型来表示秒数.

Otherwise, I'd just go with an integer type to represent the number of seconds.

这篇关于将时间跨度存储在MySQL数据库中的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆