How to use the strftime method

suggest change

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.strftime("%F %X")  #=> "2016-07-27 08:45:42"

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents