If you want to extract only the date, we can use the strftime method of Time/Date class, as
2.1.5 :055 > DateTime.now.strftime('%d/%m/%Y')
=> "12/30/2015"
(Here d is used to display date, m displays month and Y display the year in 4-digit format)
If you want to extract only the time, strftime method of Time/Date class can be used as
2.1.5 :056 > DateTime.now.strftime('%T')
=> "16:07:50"
0 Comment(s)