# difftime Function in R (Example)

This tutorial shows how to compute the time difference of two date objects with the difftime() function in the R programming language.

## Example Data

time_1 <- "2019-08-20 16:09:21" # First time object time_2 <- "2019-09-30 13:09:24" # Second time object |

time_1 <- "2019-08-20 16:09:21" # First time object time_2 <- "2019-09-30 13:09:24" # Second time object

## Calculate Time Difference with difftime Function

difftime(time_1, time_2) # Application of difftime function # Time difference of -40.87503 days |

difftime(time_1, time_2) # Application of difftime function # Time difference of -40.87503 days

The time difference of our two date objects is 40.87503 days.