Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Alex Williams http://www.alexwilliams.ca

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Formatting a date with or without the time

Ruby on Rails

This helper returns the date (and possibly the time) formatted the way you want

def format_date(date, use_time = false)
    if use_time == true
        ampm = date.strftime("%p").downcase
        new_date = date.strftime("%B %d, %Y at %I:%M" + ampm)
    else
        new_date = date.strftime("%B %d, %Y")
    end
end
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS