开发者

Twitter created_at time to unix timestamp in ruby

Is there a nice way to convert the timestamp you get from twitter (shown below) into a nice unix timestamp using ruby?开发者_开发问答

Tue, 05 Apr 2011 12:33:00 +0000

Any help would be appreciated!


Time.parse to convert it to Ruby Time and Time#to_i to get your Unix time.

# Load the Time.parse method.
require 'time'

Time.parse('Tue, 05 Apr 2011 12:33:00 +0000').to_i
#=> 1302006780
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜