You can try to convert the strings into POSIXct and simply calculate the difference:
t1 <- "2015/09/12 00:02:18"
t2 <- "2015/09/12 23:59:39"
> as.POSIXct(t2) - as.POSIXct(t1)
#Time difference of 23.95583 hours
Alternatively you may use difftime()
, a function used to calculate time differences:
> difftime(t2, t1)
#Time difference of 23.95583 hours
If you don't want to have the text in the output, you can obtain the time difference in hours with
> unclass(difftime(t2, t1, units="hours"))[1]
#[1] 23.95583
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…