简体   繁体   English

在R中读取OData日期格式

[英]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)/ . 我正在读取从OData导出的csv文件,遇到的日期格式如下: /Date(1391514600000)/

Any ideas on how to convert this into Date or POSIX in R? 关于如何将其转换为R中的DatePOSIX任何想法?

This is the Unix epoch time in milliseconds. 这是Unix纪元时间(以毫秒为单位)。

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"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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