开发者

Date formatting a Ruby date from a .NET Webservice

I have a date coming through from a .NET webservice into my Rails app:

2011-05-09T10:57:00+01:00

What date format can I use with Date.strptime which would give me a reliable way o开发者_开发技巧f extracting the date?


Date and DateTime can handle this natively:

DateTime.parse "2011-05-09T10:57:00+01:00"
# => Mon, 09 May 2011 10:57:00 +0100


@Chowlett's answer is good Or you can also try out the "strptime" method on Date. It lets you parse a string in a know format of your choosing.

http://santoro.tk/mirror/ruby-core/classes/Date.html#M000643

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜