简体   繁体   中英

How to convert from UTC to local time in R?

I have 24 values that were taken as hourly measurements (a00 to a23) in UTC (universal time) for one day for a region with a longitude of 30o . I simply want to know which one of these 24 values correspond to 1:00 am local time. Is this possible using R?

 a00=c(65);a01=c(45);a02=c(35);a03=c(25);a04=c(95);a05=c(65);a06=c(35);a07=c(25);a08=c(65);a09=c(45);a10=c(95);a11=c(85);a12=c(75);a13=c(95);a14=c(55);a15=c(35);a16=c(15);a17=c(58);a18=c(56);a19=c(54);a20=c(53);a21=c(55);a22=c(35);a23=c(15)

POSIXct automatically uses your local time

https://stat.ethz.ch/R-manual/R-devel/library/base/html/as.POSIXlt.html

# ways to convert this
as.POSIXct(z, origin = "1960-01-01")                # local
as.POSIXct(z, origin = "1960-01-01", tz = "GMT")    # in UTC

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM