RoR 4中两个日期之间的差异不正确

时间:2014-04-03 14:24:47

标签: ruby-on-rails postgresql

RoR 4.0.3 / Postgres 9.1.12

当我在PgAdmin

中执行以下查询时
SELECT extract('epoch' from expires_at) - extract('epoch' from now()) as secs_left 
FROM "auctions" ORDER BY "auctions"."id" ASC LIMIT 1

我得到expires_at(其类型为DATETIME)与当前时间(expires_at > now()为正数,否则为负数)的秒数正确值。
但是当我从rails执行查询时,我总是得到比正确值大得多的正值

@auction = Auction.select("extract('epoch' from expires_at) - extract('epoch' from now()) as secs_left").first
logger.debug @auction.secs_left

在控制台中我看到了

Auction Load (0.7ms)  SELECT *, extract('epoch' from expires_at) - extract('epoch' from now()) as secs_left FROM "auctions" ORDER BY "auctions"."id" ASC LIMIT 1
5472.91183400154

是什么原因?

0 个答案:

没有答案