JavaScript code to display Twitter created_at as xxxx ago

前端 未结 8 542
一生所求
一生所求 2020-12-24 14:51

I need some JS code that will take the created_at value from a Twitter feed and display it as xxxx ago.

I can find examples of creating the xxxx a

8条回答
  •  梦毁少年i
    2020-12-24 15:30

    May be hella late but I just found out splitting the string by spaces and creating variables accordingly, easily allows you to breakdown the date.

    // Ex. Thu Sep 28 03:40:33 +0000 2017
    
    var tweetDate = data.tweet[i].created_at;
    
    tweetDate = tweetDate.split(' ');
    
    var tweetMo = tweetDate[1];
    

提交回复
热议问题