Will West

Using Twitter's Timestamp in R

05 28 2014

Twitter's API uses a unique timestamp (see below) that doesn't work very nicely with most standard date/time text formats. Luckily, R has a nice function to convert any date/time string into standard POSIX format. Assuming you have a dataframe with a "time" column, the code below will process each timestamp as a POSIX date/time object.

# Timestamp input example: Sun Feb 28 18:35:28 +0000
format.str <- "%a %b %d %H:%M:%S %z %Y"
as.POSIXct(strptime(df[,"time"], format.str, tz = "GMT"), tz = "GMT")

This entry was tagged as R twitter python json

blog comments powered by Disqus