[R] Changing UTC time to a time zone different from system time zone

Faranak Golestaneh faranak.golestaneh at gmail.com
Sun Dec 28 15:17:56 CET 2014


Dear Friends, I’ve just started using R. I am working on a database
containing date-time as well as numeric values. Firstly I have changed the
class of the data/time column from factor to POSIXlt. Time and date are
based on UTC time but I need to change them to a local time ( not my local
time, my zone is Singapore but the data are from Australia) so I need to
change the time and date to Australia time say e.g AEST. I tried one way or
another but all failed. The following is example of the command I used.
Also one of my .CSV files is attached.

Data_Power <- read.table("train15.csv",header = TRUE, sep = ",", row.names
= NULL);

Date_clm=Data_Power$TIMESTAMP;

Date_original <- strptime(Date_clm, "%Y %m %d %H:%M", tz="GMT")

Date_local =format(Date_original, format="%c", tz="America/New_York")

Date_local <- strptime(Date_original, "%Y %m %d %H:%M +0800")

Date_local=as.POSIXlt(Date_original, "Australia/Darwin")

Date_local=as.POSIXlt(Date_original, " AEST ")

I would be so thankful if you help me out. Thanks



Cheers,

Faranak


More information about the R-help mailing list