我有这种格式的时间:
t <- "4/2/2004 12:45"
I can extract day and month using these two lines:
strptime(t, "%m/%d/%Y %H:%M", tz="UTC")$day
strptime(t, "%m/%d/%Y %H:%M", tz="UTC")$mday
Run Code Online (Sandbox Code Playgroud)
但这并没有给我我想要的岁月.我给了我没有世纪的一年:
strptime(t, "%m/%d/%Y %H:%M", tz="UTC")$year
Run Code Online (Sandbox Code Playgroud)
我怎样才能准确地获得这一年?像1987年,2012年等.而不是87和12.
如果有任何其他功能可用于此,我也可以.
添加1900.有关详细信息,请参阅详细信息部分?POSIXlt.
> tm <- "4/2/2004 12:45"
> strptime(tm, "%m/%d/%Y %H:%M", tz="UTC")$year
[1] 104
> strptime(tm, "%m/%d/%Y %H:%M", tz="UTC")$year + 1900
[1] 2004
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1832 次 |
| 最近记录: |