Created
April 2, 2013 01:41
-
-
Save erkattak/5289312 to your computer and use it in GitHub Desktop.
Throw this in an initializer and you'll be able to display date/time strings however you want. Just pass object.date_field.to_s(:time_with_zone), etc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Time::DATE_FORMATS.merge!( | |
datetime_military: '%Y-%m-%d %H:%M', | |
datetime: '%Y-%m-%d %I:%M%P', | |
time: '%l:%M%p', | |
time_with_zone: '%l:%M%p %Z', | |
time_military: '%H:%M%P', | |
datetime_short: '%m/%d %I:%M', | |
date: '%e', | |
day: '%a', | |
time_zone: '%Z', | |
date_time_long: '%A, %b %e %Y at %l:%M%p %Z', | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment