Skip to content

Instantly share code, notes, and snippets.

@orangain
Created February 6, 2014 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orangain/8842865 to your computer and use it in GitHub Desktop.
Save orangain/8842865 to your computer and use it in GitHub Desktop.
irb(main):003:0> require 'time'
=> true
irb(main):008:0> Time.strptime("2014-02-06T11:20:16.898", '%Y-%m-%dT%H:%M:%S')
=> 2014-02-06 11:20:16 +0900
irb(main):009:0> Time.strptime("2014-02-06T11:20:16Z", '%Y-%m-%dT%H:%M:%S%z')
=> 2014-02-06 11:20:16 UTC
irb(main):010:0> Time.strptime("2014-02-06T11:20:16.898Z", '%Y-%m-%dT%H:%M:%S%z')
ArgumentError: invalid strptime format - `%Y-%m-%dT%H:%M:%S%z'
from /Users/orange/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/time.rb:394:in `strptime'
from (irb):10
from /Users/orange/.rbenv/versions/2.0.0-p247/bin/irb:12:in `<main>'
irb(main):011:0> Time.parse("2014-02-06T11:20:16.898Z", '%Y-%m-%dT%H:%M:%S%z')
=> 2014-02-06 11:20:16 UTC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment