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

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