如果我这样做:
1.9.3p125 :018 > DateTime.now
=> Mon, 30 Jul 2012 16:16:57 -0700
时间有-0700 ......
但如果我这样做:
DateTime.strptime(Time.now.to_i.to_s, "%s")
=> Mon, 30 Jul 2012 23:24:46 +0000
那么它是+0000 ......我如何才能使它们相同?
答案 0 :(得分:0)
DateTime.strptime(Time.now.to_i.to_s, "%s").to_time.localtime
或
DateTime.strptime(Time.now.to_i.to_s, "%s").change(:offset => "-0700")