I try to read a NC data using ncdf soft-package, in which I read the time dimension.
ti<-get.var.ncdf(nc,varid="time")
nc$dim$time$unit
"hours since 1-1-1 00:00:0.0"
So the number is start from 1-1-1 00:00:00 with each hour
I am wondering how to transfer it to date, like 1/1/2003
Thank you
You can do as follows:
hours <- 17645592 # e.g. this is the number of hours from 01-01-01 to 2014-01-01
DATE <- as.POSIXct(x='01-01-01',tz='GMT',format='%Y-%m-%d') + (hours*60*60)
# > DATE
#[1] "2014-01-01 GMT
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.