How to get month, year, day from date in rails

    To get month, year, day from datatime you can do that simply
    Suppose you have date  2012-02-20 08:56:00 UTC in post.published_at you have to extract day from it

    <%= post.published_at.strftime("%d") %> # Show 20

    If you have to extract month Jan, Feb like this

    <%= post.published_at.strftime("%b") %> # Show Feb

    if you have to extract year

    <%= post.published_at.strftime("%Y") %> # Show 2012

    Here is list of some date formats can be used

      %a - Abbrevated Day Name (Sun)
      %A - Full Day Name (Sunday)
      %b - Abrevatted Month Name  (Jan)
      %B - Full Month Name (January)
      %c - Local Date Time Representation
      %d - Day of the month
      %H - Hour of the day, 24-hour clock
      %I - Hour of the day, 12-hour clock
      %j -   Day of the year (001..366)
      %m - Month of the year (01..12)
      %M - Minute of the hour (00..59)
      %p -  Meridian indicator (AM  or  PM)
      %S - Second of the minute (00..60)
      %y - Year without a century (00..99)
      %Y - Year with century
      %Z - Time zone name
    Average: 5 (1 vote)