Siddharth Kumar
Siddharth Kumar

Reputation: 698

Time format in twitter streamed data

{"created_at":"Mon Dec 07 17:13:02 +0000 2015","id":673913118196543488,"id_str":"673913118196543488","text":"RT @MalhotraSaurabh: I think the

How can I find all tweets which are tweeted within 5 minutes.

current_time - created_at < 5 , How to calculate ?

Upvotes: 1

Views: 181

Answers (1)

coffee-converter
coffee-converter

Reputation: 977

A regex like this should match each tweet (assuming they are always contained in {}s) and capture the date string in "created_at":

\{.*?"created_at":"([^"]*)".*?\}

Then you'll want to take those date strings and parse them into DateTime objects, something like this:

my_date = datetime.strptime(my_date_string, "%a %b %d %H:%M:%S %z %Y")

Then you can easily do your date math on that object. I hope that helps!

Upvotes: 2

Related Questions