【发布时间】:2016-08-10 22:48:59
【问题描述】:
我了解如何使用 Golang 从字符串中解析时间。
目前,我在 Rails/ruby 中发出一个由 Go 处理的请求,其中我传入了一个时间参数。
这就是我在 Rails 中所做的事情
resp = connection.get "url", {
updated_at: updated_at
}.compact
而updated_at 是Time.now - 1.day。
在 Go 中,这就是我在取出时间后解析时间的方式。
updatedAt, err := time.Parse("2006-01-02 15:04:05 -0700 MST", updatedAtVar)
如果时间看起来像,上述方法有效
2014-11-17 23:02:03 +0000 UTC
但 Ruby 吐出的时间看起来像
2016-08-10 22:29:51 +0000
其中,当解析结果时
0001-01-01 00:00:00 +0000 UTC
我可以将什么传递给我的参数,以便 go 正确解析时间?
【问题讨论】:
标签: ruby-on-rails ruby go time