Ruby Language Time How to use the strftime method

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

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"


Got any Ruby Language Question?