You can currently do that using a (probably not easy to find name) #strftime.
https://ruby-doc.org/core-2.5.1/Time.html#method-i-strftime I don't think there's a need to clone that method and make it as part of #to_s though. -Prem On Thu, Jun 28, 2018 at 1:51 AM Wilson de Almeida <wilsondealme...@gmail.com> wrote: > Hello Rails Community! > > Every time that I need to calculate a period of time and need to display > it in a custom format I use a converter that works like this code below. > > 31104002.to_s(:time, format: '%y-%m-%d %H:%M:%S') > > '01-00-00 00:00:02' > > 3602.to_s(:time, format: '%d %H:%M:%S') > > '01 00:00:02' > > 3602.to_s(:time, format: '%d days, %H hours, %M minutes and %S seconds') > > '01 days, 00 hours, 00 minutes and 02 seconds' > > Is it helpful? Interesting? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscr...@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at https://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at https://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.