Format DateTime in Text Box in Rails

前端 未结 7 1826
生来不讨喜
生来不讨喜 2021-01-31 18:59

Is there an easy way to format the display of a DateTime value in a Rails view?

For example, if I\'m doing something like:

<%= text_field         


        
7条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-31 19:41

    if you don't want to enter the date in a textfield, but in a less error prone select field, you could use the ActionView::Helpers::DateHelper, select_date(). see Accessing date() variables send from the date helper in rails here on SO on how to process the return values.

提交回复
热议问题