2

I'm trying to convert a column of timestamps from GMT to CST6CDT. I've tried a number of methods and I can successfully change the timezone shown on the timestamp, but it doesn't actually convert the time.

> attributes(timestamp)

$class [1] "POSIXct" "POSIXt"

$tzone [1] "GMT"

head(timestamp) [1] "2014-04-21 19:47:00 GMT" "2014-04-21 20:09:00 GMT" "2014-04-24 17:22:00 GMT" "2014-04-25 14:23:00 GMT" [5] "2014-04-25 15:40:00 GMT" "2014-04-25 18:24:00 GMT"

> timestamp2 <- force_tz(timestamp, tzone = "CST6CDT")

head(timestamp2) [1] "2014-04-21 19:47:00 CDT" "2014-04-21 20:09:00 CDT" "2014-04-24 17:22:00 CDT" "2014-04-25 14:23:00 CDT" [5] "2014-04-25 15:40:00 CDT" "2014-04-25 18:24:00 CDT"

I've also tried 2 other methods:

as.POSIXct(timestamp, tz="CST6CDT")
attributes(timestamp)$tzone <- "CST6CDT"

But the result is the same. It makes me think that there's an issue with the timestamp column itself.

I generated timestamp from another data set called action_timestamp:

head(action_timestamp) [1] "4/21/14 7:47 PM" "4/21/14 8:09 PM" "4/24/14 5:22 PM" "4/25/14 2:23 PM" "4/25/14 3:40 PM" [6] "4/25/14 6:24 PM"

timestamp <- strptime(action_timestamp, format="%m/%d/%y %I:%M %p")

Any ideas to why I'm unable to successfully convert timezones?

aiolias
  • 849
  • 1
  • 6
  • 8

0 Answers0