Transform DateTime into simple Date in Ruby on Rails

前端 未结 6 806
不思量自难忘°
不思量自难忘° 2021-01-30 08:09

I have a datetime column in db that I want to transform into a simple date when I show it to users.

How can I do that?

def shown_date
  # to_date does not exi         


        
6条回答
  •  孤独总比滥情好
    2021-01-30 08:38

    Try converting the entry to a string first. As long as the database column type is a date it will be formated as a date.

    self.date || self.exif_date_time_original.to_s

提交回复
热议问题