0
我在我的应用程序中有一个Timekeeper
模型。它跟踪起始时间和完成时间。我想取这两个datetimes
之间的差异,并提取秒并将该值作为整数存储在数据库中。这是我目前的工作。在数据库中存储秒 - Rails
方法:
((timekeeper.started_at - Time.current) * 24 * 60 * 60).to_i
这将返回一个类似如下的值:-2336036
上述两个时间只差12秒分开,我得到的价值。我不确定它在说什么。
从我的问题的外卖是:How can I store seconds in the database, between two datetimes that looks similar to what I'm doing currently?