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 应用程序中有一个日期字段,但是当我发送值时,2013-01-12T05:46:01Z它显示无效的 json 字符串。我也尝试过发送2012-02-14 05:00:00,但这也显示相同的错误,但是当我发布20120214050000+0000它时接受了日期。那么我如何发布日期的值?
2013-01-12T05:46:01Z
2012-02-14 05:00:00
20120214050000+0000
您可以使用Time.parse(string)
Time.parse(string)
或者您可以向要在其中插入日期的模型添加一个方法
或者你可以使用慢性宝石。
看看这个Rails Cast