sampleDate <- "08/15/2015 00:00"
sampleDateObject <- strptime(sampleDate, "%m/%d/%Y %H:%M")
现在如何从这个sampleDateObject获取日,年,月等?
答案 0 :(得分:1)
sampleDateObject[['year']]
将返回115,这是1900年之后的年数。详情请见?POSIXlt
。
答案 1 :(得分:0)
好的,我找到了答案。
sampleDateObject$mon # to access month from 0-11
要访问其他属性,请查看此页面 https://stat.ethz.ch/R-manual/R-devel/library/base/html/DateTimeClasses.html