Posted By

alexwilliams on 01/01/07


Tagged

date format rails ruby helper


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


Formatting a date with or without the time


 / Published in: Ruby
 

  1. def format_date(date, use_time = false)
  2. if use_time == true
  3. ampm = date.strftime("%p").downcase
  4. new_date = date.strftime("%B %d, %Y at %I:%M" + ampm)
  5. else
  6. new_date = date.strftime("%B %d, %Y")
  7. end
  8. end

Report this snippet  

You need to login to post a comment.