Last active
December 21, 2015 20:18
-
-
Save andilabs/6360270 to your computer and use it in GitHub Desktop.
datatime difference in R
strptime
difftime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x1<-"2013-03-03 23:26:46.315558" | |
x2<-"2013-03-03 23:31:53.091022" | |
x1 <- strptime(x1, "%Y-%m-%d %H:%M:%OS") | |
x2 <- strptime(x2, "%Y-%m-%d %H:%M:%OS") | |
x2 | |
[1] "2013-03-03 23:31:53" | |
x1 | |
[1] "2013-03-03 23:26:46" | |
x2-x1 | |
Time difference of 5.112924 mins | |
as.numeric(x2-x1) | |
[1] 5.112924 | |
op <- options(digits.secs = 3) | |
x2 | |
[1] "2013-03-03 23:31:53.091" | |
as.numeric(x2-x1,units="secs") | |
[1] 306.776 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment