1
{"creator"=>{"siteStandardProfileRequest"=>{"url"=>"http://www.linkedin.com/profile?viewProfile=&key=966636&authToken=TVqk&authType=name&trk=api*a188142*s196271*"}, "lastName"=>"Emge", "id"=>"EZDn5fpc6X", "pictureUrl"=>"http://m3.licdn.com/mpr/mprx/0_gxkFOrh6iNKSaMhhxOX4OPnLizvm2VTh0ZKZOPFJpPTY1Yn8AMNIK1PcD4zl7j82yyQJAqJM7R4U", "firstName"=>"Ryan O."}, "creationTimestamp"=>1355124057000, "text"=>"Being that it positions itself as a the backbone of the internet, it appears that there will be many long term opportunities in this space.", "id"=>"g-66325-S-194331620-108220061"}

しかし、creationTimestampはこの形式です1355124057000。に変更したいSat Dec 15 04:13:14 +0000 2012。レール、Ruby 1.8.7、Rails 3.0.4でRubyを使用してい
ます。これを変更するにはどうすればよいですか?

4

1 に答える 1

1

私はあなたがTime.at機能を探していると思います

t = Time.at(1355124057) # for seconds since epoch
t = Time.at(1355124057000/1000) # for milliseconds since epoch

これは、エポック(1970年1月1日00:00:00 GMT)からの秒単位の時間です。

時間オブジェクトを取得したら、好きな方法で時間を文字列に変換するためにt適用しますstrftime

だからあなたの場合、それは

t.strftime("%a %b %d %H:%m:%S %z %Y")
于 2012-12-15T04:25:03.843 に答える