Here is an example with print statements after each step so you can see the logic of the code.
library(dplyr)
DF <- data.frame(DateTime = as.POSIXct(c("2020-04-01 00:00:00",
"2020-04-01 00:23:02",
"2020-04-01 01:45:15",
"2020-04-01 9:41:18")))
DF
#> DateTime
#> 1 2020-04-01 00:00:00
#> 2 2020-04-01 00:23:02
#> 3 2020-04-01 01:45:15
#> 4 2020-04-01 09:41:18
DF <- DF %>% mutate(DateTimeLag = lag(DateTime))
DF
#> DateTime DateTimeLag
#> 1 2020-04-01 00:00:00 <NA>
#> 2 2020-04-01 00:23:02 2020-04-01 00:00:00
#> 3 2020-04-01 01:45:15 2020-04-01 00:23:02
#> 4 2020-04-01 09:41:18 2020-04-01 01:45:15
DF <- DF %>% mutate(Interval = DateTime - DateTimeLag)
DF
#> DateTime DateTimeLag Interval
#> 1 2020-04-01 00:00:00 <NA> NA mins
#> 2 2020-04-01 00:23:02 2020-04-01 00:00:00 23.03333 mins
#> 3 2020-04-01 01:45:15 2020-04-01 00:23:02 82.21667 mins
#> 4 2020-04-01 09:41:18 2020-04-01 01:45:15 476.05000 mins
Created on 2020-04-08 by the reprex package (v0.3.0)