开发者

What is the best way to store duration in MySQL

I need to store duration (number of minutes and/or hours and/or days). I have looked at MySQL type, but DATE and TIME types seems to be used to store a specific date in time. Not a duration.

I thinking about using a int to store the number of开发者_如何学Go second, and convert it in the PHP for display.


You seem to have the answer yourself. You can store the number of milliseconds(or any unit) in the duration as a number and convert it to the unit that you wish in the application.


You can store the value as a number.


You might not necessarily need to store it, either, if it's being calculated from data already in your table you could run a math query: SELECT time1-time2 FROM table_name

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜