2012-04-12 3 views
2

私は検索APIを使用して、いくつかのつぶやきをインポートして返すJSONを取得しています:ツイートの年齢を取得するにはどうすればいいですか?

"results": [ 
    { 
     "created_at": "Thu, 12 Apr 2012 04:58:01 +0000", 
     "from_user": "AdamHills", 
     "from_user_id": 23045431, 
     "from_user_id_str": "23045431", 
     "from_user_name": "Adam Hills", 
     "geo": null, 
     "id": 190302731255287800, 
     "id_str": "190302731255287808", 
     "iso_language_code": "sv", 
     "metadata": { 
      "result_type": "recent" 
     }, 
     "profile_image_url": "http://a0.twimg.com/profile_images/1350305654/goteborgs-rape_normal.jpg", 
     "profile_image_url_https": "https://si0.twimg.com/profile_images/1350305654/goteborgs-rape_normal.jpg", 
     "source": "<a href="http://twitter.com/#!/download/iphone" rel="nofollow">Twitter for iPhone</a>", 
     "text": "@Adde77 Den ska finnas tillgänglig i slutet av april.", 
     "to_user": "Adde77", 
     "to_user_id": 99782511, 
     "to_user_id_str": "99782511", 
     "to_user_name": "Adde P", 
     "in_reply_to_status_id": 190222715716763650, 
     "in_reply_to_status_id_str": "190222715716763648" 
    } 

は、どのように私は、その特定のつぶやきの年齢を取得することができますので、私は私のページに4m agoのようなものをプリントアウトすることができますか?それで、created_atの文字列が混乱して見えます!簡単な方法はありますか?

+1

そのがhttps://github.com/jzaefferer/jquery-prettydate/blob/master/jquery.prettydate.js行ってどのように表示するには、このコードを確認 – GillesC

答えて

2

日付形式は標準です。

Dateオブジェクトを作成して、それを操作してください。

var tweet_date = new Date("Thu, 12 Apr 2012 04:58:01 +0000"); 
関連する問題