开发者

Twitter created_at time to unix timestamp in ruby

开发者 https://www.devze.com 2023-02-22 14:14 出处:网络
Is there a nice way to convert the timestamp you get from twitter (shown below) into a nice unix timestamp using 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

精彩评论

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