这是我的转换日期: " 16:00:00 CT 08年4月8日"
这是我的尝试:
x <- "16:00:00 CT 08 Apr 2018"
Sys.setlocale(category = "LC_ALL", locale = "English_United States.1252")
as.POSIXct(x, format = '%H:%M:%S %A %d %b %Y')
并返回NA
答案 0 :(得分:4)
我们可以在CT
format
as.POSIXct(x, format = '%H:%M:%S CT %d %b %Y')
答案 1 :(得分:1)
删除字符串CT
并继续前进:
as.POSIXct(paste(unlist(strsplit(x," CT ")),collapse = ""),format='%H:%M:%S %d %b %Y')
[1] "2018-04-08 16:00:00 GMT"