I have a data frame with RFC 3339 format ("2012-04-12T19:02:32Z") and I need to turn into a date type R, I found as.POSIXct function but can not use it properly.
Asked
Active
Viewed 1,010 times
0
-
If `x` is your date - try `as.POSIXct(x,format="%Y-%m-%dT%H:%M:%SZ",tz="UTC")` see - `?strptime` for all the details of the date specifiers. – thelatemail Sep 04 '14 at 00:34
-
Beat me by a minute. Post it as an answer... – Dirk Eddelbuettel Sep 04 '14 at 00:36
1 Answers
2
Try this:
R> as.POSIXct("2012-04-12T19:02:32Z", format="%Y-%m-%dT%H:%M:%SZ")
[1] "2012-04-12 19:02:32 CDT"
R>
The arguments for the format string are detailed in the help page.

Dirk Eddelbuettel
- 360,940
- 56
- 644
- 725
-
I think the `Z` at the end signifies `UTC` - if so it probably should be forced to that `tz`. – thelatemail Sep 04 '14 at 00:38
-
what's the difference between BRT and UTK? And Thanks a lot for the help =D – user2905427 Sep 04 '14 at 00:45
-
@user2905427 - I have no idea. This is the first I've heard of BRT and UTK? – thelatemail Sep 04 '14 at 00:48
-
No, but I do not know what the best to use with R language, I will use graphs with Igraphs, any suggest? – user2905427 Sep 04 '14 at 00:57