如何四舍五入到最近的未来时间戳?
How to round to the nearest future timestamp?
我正在使用 lubridate 函数 round_date 来舍入时间戳,如下所示:
round_date(as.POSIXct("2015-11-26 23:51:15"),"5 mins")
这给出了“2015-11-26 23:50:00 +08”
但我想将它四舍五入到未来 5 分钟而不是过去。喜欢
round_date(as.POSIXct("2015-11-26 23:51:15"),"5 mins")
应该四舍五入从 2015-11-26 23:50:01
到 2015-11-26 23:54:59
再到
的所有时间戳
2015-11-26 23:55:00.
感谢任何帮助。
这应该有效。
lubridate::ceiling_date(as.POSIXct("2015-11-26 23:54:49"),"5 mins")
将所有时间戳从 2015-11-26 23:50:01
舍入到 2015-11-26 23:54:59
再到 2015-11-26 23:55:00
。
我正在使用 lubridate 函数 round_date 来舍入时间戳,如下所示:
round_date(as.POSIXct("2015-11-26 23:51:15"),"5 mins")
这给出了“2015-11-26 23:50:00 +08”
但我想将它四舍五入到未来 5 分钟而不是过去。喜欢
round_date(as.POSIXct("2015-11-26 23:51:15"),"5 mins")
应该四舍五入从 2015-11-26 23:50:01
到 2015-11-26 23:54:59
再到
2015-11-26 23:55:00.
感谢任何帮助。
这应该有效。
lubridate::ceiling_date(as.POSIXct("2015-11-26 23:54:49"),"5 mins")
将所有时间戳从 2015-11-26 23:50:01
舍入到 2015-11-26 23:54:59
再到 2015-11-26 23:55:00
。