Convert date from 2019-04-30 11:29:24 format to 30-April-2019 11:29:24 format using lubridate in R.
Conversion from ymd_hms to dmy_hms.
# sample date
date_as_string <- "2019-04-30 11:29:24"
# without lubridate
format(x = as.POSIXct(x = date_as_string),
format = "%d-%B-%Y %H:%M:%S")
#> [1] "30-April-2019 11:29:24"
# using lubridate
format(x = lubridate::ymd_hms(date_as_string),
format = "%d-%B-%Y %H:%M:%S")
#> [1] "30-April-2019 11:29:24"
Hope this helps.
3 Likes
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.