I have a problem with dates in R. Define T1 and T2 as dates in POSIXct or POSIXlt format with 6 fractional seconds:
op <- options(digits.secs = 6) T1 = strptime("2015.10.10 12:00:00.150150", "%Y.%m.%d %H:%M:%OS") T2 = strptime("2015.10.10 16:30:15.212412", "%Y.%m.%d %H:%M:%OS")
How to get the difference between T1 and T2 in this format:
format = "%H:%M:%OS"
For example, the difference between certain dates:
diff = "04:30:15.062262"
I tried different approaches, but that was unsuccessful.
My attempts:
T1 = strptime("2015.10.10 12:00:00.150150", "%Y.%m.%d %H:%M:%OS") T2 = strptime("2015.10.10 16:30:15.212412", "%Y.%m.%d %H:%M:%OS") h = difftime(T2,T1, units = "hours") m = difftime(T2,T1, units = "mins") s = difftime(T2,T1, units = "secs")
But I do not know how to get fractional numbers.
source share