JavaScript code to display Twitter created_at as xxxx ago

前端 未结 8 558
一生所求
一生所求 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条回答
  •  别那么骄傲
    2020-12-24 15:32

    Using moment.js without any plugin this is the custom format you need to use to parse the awkward Twitter date properly:

    var tweetDate = 'Mon Dec 02 23:45:49 +0000 2013';
    moment(tweetDate, 'dd MMM DD HH:mm:ss ZZ YYYY', 'en');
    

提交回复
热议问题