Something wrong in convert ISO 8601 date/times with a 'POSIXct' object

r

Solution

Use the correct format:

as.POSIXct(pb.txt, "%Y-%m-%dT%H:%M:%S", tz="UTC")
[1] "2012-09-11 21:23:20 UTC"

Problem

There is something I don't understand. I simply try to convert a date in an other time zone. The date is in the 8601-ISO format. I followed this. ``` pb.txt <- "2012-09-11T21:23:20Z" pb.date <- as.POSIXct(pb.txt, tz="UTC") format(pb.date, tz="WEST",usetz=TRUE) [1] "2012-09-11 WEST" ``` Why only the date appears and not anymore the timestamp ? I tried also : ``` pb.date <- as.POSIXct(pb.txt, origin=ISOdatetime(2012,09,11,21,23,20)) format(pb.date, tz="WEST",usetz=TRUE) [1] "2012-09-10 22:00:00 WEST ``` It's better, but the timestamp is rounded. How to convert perfectly an 8601-ISO datetime ?

Original source

Related problems