I researched how to change the display format of Time objects in Ruby, so here’s a memo.
Time.now.strftime("%Y-%m-%d %H:%M:%S") #=> "2011-11-13 00:31:21"
For example, suppose you want to display a PostgreSQL timestamp type value like a date type value.
If the start_at record of the event table is a timestamp type, you can write it as follows:
@event.start_at.strftime("%Y-%m-%d") #=> "2011-11-13"
That’s all.
【References】
That’s all from the Gemba.