12
A
回答
33
您可以尝试
library(lubridate)
seconds_to_period(86400)
#[1] "1d 0H 0M 0S"
seconds_to_period(48000)
#[1] "13H 20M 0S"
如果需要format
td <- seconds_to_period(86400)
sprintf('%02d %02d:%02d:%02d', day(td), [email protected], minute(td), second(td))
#[1] "01 00:00:00"
如果它跨越了>99
天,
td <- seconds_to_period(1e7)
sprintf('%03d %02d:%02d:%02d', day(td), [email protected], minute(td), second(td))
#[1] "115 17:46:40"
0
这也适用于使用seconds.to.hms
从kimisc
,虽不像@ak一样优雅运行的回答是:
library(kimisc)
library(dplyr)
library(stringr)
HMS = seconds.to.hms(86400)
HMS = seconds.to.hms(48000)
HMS = seconds.to.hms(1e7)
HMS %>%
str_extract("^\\d+") %>%
as.numeric() %>%
{paste(.%/%24, .%%24)} %>%
str_replace(HMS, "^\\d+", .)
结果:
[1] "1 0:00:00"
[1] "0 13:20:00"
[1] "115 17:46:40"
相关问题
- 1. 将秒转换为小时和分钟
- 2. C++转换小时,分钟,秒到秒
- 3. php - 转换小时:分钟:秒。秒
- 4. 如何将270921sec转换为天+小时+分钟+秒? (红宝石)
- 5. 将秒转换为分钟,小时和天的Java代码
- 6. SQL将毫秒转换为天,小时,分钟
- 7. 将工作秒数转换为周,天,小时和分钟
- 8. 将NSTimeInterval转换为天,小时,分钟,秒
- 9. 将负秒转换为小时:分:秒
- 10. 如何将秒转换为小时分钟和秒?
- 11. 将毫秒转换为小时,分钟和秒python
- 12. 如何将小时,分钟和秒转换为秒
- 13. 如何将秒转换为小时:分钟:秒在php
- 14. 将秒转换为小时,分钟,seconds.hundreths第二秒
- 15. 如何将毫秒,秒,分钟,小时转换为SQL Server 2005中的天数?
- 16. 将毫秒转换为天,小时,分和秒
- 17. 将秒转换为天,小时,分和秒
- 18. 将秒转换为天,分和秒
- 19. 时间戳为天,小时,分钟,秒
- 20. 将分钟转换为小时,分钟和秒
- 21. 将小时,分钟,秒转换为小时字符串
- 22. 分钟,秒转换为毫秒
- 23. 如何将秒分别转换为年,月,日,小时,分钟?
- 24. Python时间转换器从秒到几天,几小时,几分钟和几秒
- 25. 将秒数转换为总时数:分钟:秒
- 26. 如何在JavaScript中将时间毫秒转换为小时,分钟,秒格式?
- 27. 如何将Java时代以来的秒数转换为小时/分钟/秒?
- 28. 将十进制表示时间转换为小时,分钟,秒
- 29. 将ISO8601(我认为)转换为小时:分钟:Powershell中的秒
- 30. 如何显示在天毫秒为单位:小时:分钟:秒