Tutorial by Examples

Converting a time to a string is a pretty common thing to do in Ruby. strftime is the method one would use to convert time to a string. Here are some examples: Time.now.strftime("%Y-%m-d %H:%M:S") #=> "2016-07-27 08:45:42" This can be simplified even further Time.now.str...
Get current time: Time.now Time.new # is equivalent if used with no parameters Get specific time: Time.new(2010, 3, 10) #10 March 2010 (Midnight) Time.new(2015, 5, 3, 10, 14) #10:14 AM on 3 May 2015 Time.new(2050, "May", 3, 21, 8, 16, "+10:00") #09:08:16 PM on 3 May 2050...

Page 1 of 1