sen*_*hil 5 ruby time timezone
我有这个字符串:
10 月 7 日星期日下午 4:00
当我使用 时Time.parse
,Ruby 假定时区是 UTC。我如何告诉 Ruby 给我 -0700 时区?我试过使用
tz.utc_to_local(Time.parse(string))
Run Code Online (Sandbox Code Playgroud)
但我仍然得到 UTC +0000 时区。
小智 0
确保您的时区设置正确
config.time_zone = 'Eastern Time (US & Canada)'
Run Code Online (Sandbox Code Playgroud)
Time.parse 应默认为当前时区,但您也可以尝试
Time.parse('####').in_time_zone
Run Code Online (Sandbox Code Playgroud)