【发布时间】:2012-07-30 21:31:51
【问题描述】:
这是来自 Postgres 的查询结果:
$ psql ... -c 'select the_date from foo where foo_id in (998,999)'
the_date
------------------------
2012-03-07 09:34:47.98
2012-03-16 11:31:25.336
the_date 是“没有时区的时间戳”。
这是一个 Ruby 程序:
#!/usr/bin/env ruby
require 'sequel'
@DB = Sequel.connect({...})
query = "select the_date from foo where foo_id in (998,999)"
@DB[query].each do |row|
warn row
end
还有一些输出:
{:the_date=>2012-03-07 09:34:47 -0600}
{:the_date=>2012-03-16 11:31:25 -0500}
-0500 和 -0600 从何而来?那是服务器和客户端机器(美国/中部)的“Olson timezone”,但是为什么Ruby添加它而psql没有呢?
我一直在阅读the docs,我完全糊涂了。
服务器是Postgres 9.0.4,客户端是psql 9.1.4,sequel是3.33.0。
【问题讨论】:
-
您可以在closely related question 找到有用的信息。
标签: ruby postgresql timezone