[R] Clean method to convert date and time between time zones keeping it in POSIXct format

Arnaud Mosnier a.mosnier at gmail.com
Mon May 9 15:24:11 CEST 2016

Dear UseRs,

I know two ways to convert dates and time from on time zone to another but
I am pretty sure that there is a better (cleaner) way to do that.

Here are the methods I know:

## The longest way ...

T1 <- as.POSIXct("2016-05-09 10:00:00", format="%Y-%m-%d %H:%M:%S",


T2 <- as.POSIXct(format(T1, tz="UTC"), tz="UTC") # format convert it to
character, so I have to convert it back to POSIXct afterward.


## The shortest but probably not the cleanest ...

attributes(T1)$tzone <- "UTC"


	[[alternative HTML version deleted]]

More information about the R-help mailing list