# Drexed-DateTime Helpers for human readable datetime attributes. ## Installation Add this line to your application's Gemfile: gem 'drexed-datetime' And then execute: $ bundle Or install it yourself as: $ gem install drexed-datetime ## Datetime helpers ```ruby <%= date_for(@variable.created_at) %> ``` | Helper | `strftime` equivalent | | --- | --- | | year_for | 2013 | | month_name_for | December | | abbr_month_name_for | Dec | | day_number_for | 5 | | day_name_for | Friday | | abbr_day_name_for | Fri | | twelve_hour_time_for | 07:13 PM | | twelve_hour_time_with_timezone_for | 07:13 PM EST | | twenty_four_hour_time_for | 19:12 | | twenty_four_hour_time_with_timezone_for | 19:12 EST | | month_day_and_time_for | December 4 at 07:11 PM | | abbr_month_day_and_time_for | Dec 4 at 07:11 PM | | month_day_and_time_with_timezone_for | December 4 at 07:11 PM EST | | abbr_month_day_and_time_with_timezone_for | Dec 4 at 07:11 PM EST | | datetime_for | December 4, 2013 at 07:11 PM | | abbr_datetime_for | Dec 4, 2013 at 07:17 PM | | datetime_with_timezone_for | December 4, 2013 at 07:11 PM EST | | abbr_datetime_with_timezone_for | Dec 4, 2013 at 07:17 PM EST | | date_for | December 4, 2013 | | abbr_date_for | Dec 4, 2013 | | month_and_day_for | December 4 | | abbr_month_and_day_for | Dec 4 | | timezone_name_for | EST | ## Datetime formatter ```ruby Time.now.datetime_to("yyyy-mm-dd") => "2012-03-04" Time.now.datetime_to("M d, yy") => "Mar 4, 12" Time.now.datetime_to("hh:mi p") => "02:06 pm" ``` | Format string | `strftime` equivalent | Output for `t` | | --- | --- | --- | | "yyyy" | "%Y"| 2013| | "yy" | "%y"| 13| | "mm" | "%m" | 03 | | "m" | "%-m" | 3 | | "MM" | "%B" | March | | "M" | "%b" | Mar | | "dd" | "%d" | 04 | | "d" | "%-d" | 4 | | "DD" | "%A" | Sunday | | "D" | "%a" | Sun | | "hh" | "%I" | 02 | | "h" | "%l" | 2 | | "HH" | "%H" | 14 | | "H" | "%-H" | 14 | | "mi" | "%M" | 06 | | "p" | "%P" | pm | | "P" | "%p" | PM |