lubridate makes it easier to work with dates and time. library(lubridate); for (sec in seq(36300, 92000, by=7*60)) { sec_p <- seconds_to_period(sec); hr_mi <- sprintf('%02d:%02d', sec_p@hour, minute(sec_p)); print(hr_mi); }
library(lubridate)
dt_1 <- ymd('20170213')
dt_2 <- mdy('09282016')
dt_3 <- dmy('22032017')
dt_1
# [1] "2017-02-13 UTC"
dt_2
# [1] "2016-09-28 UTC"
dt_3
# [1] "2017-03-22 UTC"