您如何将POSIX日期转换为一年中的某一天?

您如何将POSIX日期转换为一年中的某一天?

问题描述:

标题如下:

使用 strftime()格式化 POSIXt 对象:

R> today <- Sys.time()
R> today
[1] "2012-10-19 19:12:04 BST"
R> doy <- strftime(today, format = "%j")
R> doy
[1] "293"
R> as.numeric(doy)
[1] 293

在POSIX标准中,年份中的一天是从零开始的。

which is preferable to remembering that the day of the years is zero-based in the POSIX standard.