简体   繁体   中英

reading OData date format in R

I am reading a csv file exported from OData, and encounter a date format that looks like this: /Date(1391514600000)/ .

Any ideas on how to convert this into Date or POSIX in R?

This is the Unix epoch time in milliseconds.

x <- "/Date(1391514600000)/"
x <- as.numeric(gsub("[^0-9]", "", x))
x
# [1] 1391514600000

# from milliseconds to seconds:
x <- x / 1000
as.POSIXct(x, origin="1970-01-01", tz="GMT")
# [1] "2014-02-04 11:50:00 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.

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