Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有像年月这样的整数值,但我不会看到月年,我怎么能在 Rails 视图中做到这一点?例如
197903 198812
必须被视为
03-1979 12-1988
尝试这个
"#{197903.to_s[0...4]}-#{197903.to_s[4...6]}"
如果您可以先将其转换为日期对象,则可能会有更优雅的方式来执行此操作。