如果你有单独的字符串,那么
as.POSIXlt(paste(date, time), format="%d/%m/%Y %H:%M:%S")
应该有用。例子:
as.POSIXlt(paste("16/12/2006", "17:24:00"), format="%d/%m/%Y %H:%M:%S")
# [1] "2006-12-16 17:24:00"
第二点,
$month
和
$day
不可用的属性您可以看到以下属性:
dput(as.POSIXlt(Sys.time()))
# structure(list(sec = 48.7993450164795, min = 17L, hour = 0L,
# mday = 18L, mon = 6L, year = 118L, wday = 3L, yday = 198L,
# isdst = 1L, zone = "PDT", gmtoff = -25200L), .Names = c("sec",
# "min", "hour", "mday", "mon", "year", "wday", "yday", "isdst",
# "zone", "gmtoff"), class = c("POSIXlt", "POSIXt"), tzone = c("",
# "PST", "PDT"))
表明你真正需要的是
$mon
和
$mday
.