Skip to content

Instantly share code, notes, and snippets.

@johno
Created February 15, 2014 18:31
Show Gist options
  • Save johno/9023255 to your computer and use it in GitHub Desktop.
Save johno/9023255 to your computer and use it in GitHub Desktop.
The strftime method shows all the Ruby directives for different representations of time. This allows you to deal with tricky scenarios of ambiguous timestamps.
~|||$ irb
re2.0.0p353 :001 > require 'Time'
=> true
2.0.0p353 :002 > Time.strptime("12/22/2011", "%m/%d/%Y")
=> 2011-12-22 00:00:00 -0700
2.0.0p353 :003 > Time.strptime("12/11/2011", "%m/%d/%Y")
=> 2011-12-11 00:00:00 -0700
2.0.0p353 :004 > Time.strptime("12/11/2011", "%d/%m/%Y")
=> 2011-11-12 00:00:00 -0700
2.0.0p353 :005 >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment