How can I use US-style dates in Rails using Ruby 1.9?

后端 未结 7 1834
攒了一身酷
攒了一身酷 2021-01-04 09:21

I\'m in the U.S., and we usually format dates as "month/day/year". I\'m trying to make sure that my Rails app, using Ruby 1.9, assumes this format everywhere, and

7条回答
  •  别那么骄傲
    2021-01-04 10:11

    Date.strptime is probably what you're looking for in ruby 1.9.

    You're probably stuck monkeypatching it onto string.to_date for now, but strptime is the best solution for parsing dates from strings in ruby 1.9.

    Also, the formats are symmetric with strftime as far as I know.

提交回复
热议问题