date format error message in R

The difftime() function only takes POSIXct or date class objects as arguments and you are passing string class values. You need to convert them first, take a look at this example:

difftime(as.POSIXct("4/1/2019 0:03", format = "%m/%d/%Y %H:%M", tz = "UTC"),
         as.POSIXct("4/1/2019 0:02", format = "%m/%d/%Y %H:%M", tz = "UTC"))
#> Time difference of 1 mins

Created on 2022-09-18 with reprex v2.0.2

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.