Format time as '%m-%d-%Y %I:%M:%S %p' : strftime « Time « Ruby






Format time as '%m-%d-%Y %I:%M:%S %p'


time = Time.gm(2005, 12, 31, 13, 22, 33)
twelve_hour_clock_time = '%m-%d-%Y %I:%M:%S %p'
time.strftime(twelve_hour_clock_time)      # => "12-31-2005 01:22:33 PM"

 








Related examples in the same category

1.Time#strftime directives
2.Time.gm(2006).strftime('The year is %Y!')
3.Format time as '%D'
4.Format time as '%d/%m/%y'
5.Format time as '%m/%d/%Y'
6.Format time as '%m-%d-%Y %H:%M:%S %Z'
7.Format time as '%A, %B %d, %Y'
8.strftime("%U") and strftime("%W")