Handling Heterogeneous datetime formats
We`ll be using parse_date_time function of lubridate package.
Multple datetime formats can be passed under orders attribute of the above function as shown below -
library(lubridate)
dates <- c( "1/22/2020 17:00", "2020-02-02 09:43:01", "2/1/2020 11:53")
parse_date_time(dates, orders = c('%Y-%m-%d %H:%M;%S','%m/%d/%Y %H:%M', '%m/%d/%y %H:%M'))
Output -
## [1] "2020-01-22 17:00:00 UTC" "2020-02-02 09:43:01 UTC"
## [3] "2020-02-01 11:53:00 UTC"