Skip to content

Instantly share code, notes, and snippets.

@yoggy
Created May 16, 2018 11:40
Show Gist options
  • Select an option

  • Save yoggy/d41db19b57cdc6a6d7d11f7d5e661241 to your computer and use it in GitHub Desktop.

Select an option

Save yoggy/d41db19b57cdc6a6d7d11f7d5e661241 to your computer and use it in GitHub Desktop.
RubyのTime.parseはタイムゾーンが付いていない文字列をローカルタイムゾーンの時刻として解釈する。
$ irb -r time
irb(main):001:0> Time.parse("2018-1-1 0:0:0.0")
=> 2018-01-01 00:00:00 +0900
irb(main):002:0> Time.parse("2018-1-1 0:0:0.0 UTC")
=> 2018-01-01 00:00:00 UTC
irb(main):003:0> Time.parse("2018-1-1 0:0:0.0 UTC").localtime
=> 2018-01-01 09:00:00 +0900
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment