Convert UTC time to local standard time in R

I am trying to convert UTC time to local standard time. I found many features that convert to Local Daylight Time, but I was not able to get the standard time. Right now, I have the following code that will convert to local daytime in my specific time zone:

pb.date <- as.POSIXct(date,tz="UTC")
format(pb.date, tz="timeZone",usetz=TRUE)

I would be grateful for any help.

+4
source share
1 answer

First, POSIXct date-times is always UCT internally. Methods print.POSIXtand, format.POSIXtaccordingly, will shift TZ at the exit from their internal representations:

pb.date <- as.POSIXct(Sys.Date())
Sys.Date()
#[1] "2015-07-09"

So, it was midnight of the current date in Greenwich:

format(pb.date, tz="America/Los_Angeles",usetz=TRUE)
#[1] "2015-07-08 17:00:00 PDT"

, 5 . TZ ( ), .

8 , , / :

> format(pb.date,usetz=TRUE, tz="Etc/GMT+8")
[1] "2015-07-08 16:00:00 GMT+8"

( + "" - "".)

+3

All Articles