Convert Twitter Timestamp in R

后端 未结 3 1120

I am new to R and am terrible with handling dates. The following date is returned from a query to the Twitter search API and is stored as a character string in a my dataframe.<

3条回答
  •  旧巷少年郎
    2021-02-09 19:49

    From the help(strptime):

    > Sys.setlocale("LC_TIME", "C")
    [1] "C"
    > strptime("Tue, 23 Mar 2010 14:36:38 -0400",
    +          "%a, %d %b %Y %H:%M:%S %z",
    +          tz="GMT")
    [1] "2010-03-23 18:36:38 GMT"
    

    Be careful about the locale: if you don't reset it to C, the function will try to parse weekday and month abbreviations as localized.

提交回复
热议问题