Formato de fechas en Ruby

Para cuando trabajamos con fechas:

 

time = Time.now # => Thu Jan 18 06:10:17 CST 2015

time.to_formatted_s(:time) # => “06:10”
time.to_s(:time) # => “06:10”

time.to_formatted_s(:db) # => “2015-01-18 06:10:17”
time.to_formatted_s(:number) # => “20150118061017”
time.to_formatted_s(:short) # => “18 Jan 06:10”
time.to_formatted_s(:long) # => “January 18,2015 06:10”
time.to_formatted_s(:long_ordinal) # => “January 18th, 2015 06:10”
time.to_formatted_s(:rfc822) # => “Thu, 18 Jan 2015 06:10:17 -0600”

http://ruby-doc.org/core-1.9.3/Time.html#method-i-strftime

ruby on rails

Leave a Reply

Your email address will not be published. Required fields are marked *