I assume the value starts as a character, so I convert it to POSIXct and then back to a character with the desired format. I put in unnecessary calls to str() to illustrate how the class of the column changes. Note that the final form is not a numeric date-time, so you cannot do calculations with it, at least not conveniently.
DF <- data.frame(time_open = "2019-04-21T00:00:01.000Z", stringsAsFactors = FALSE)
str(DF)
#> 'data.frame': 1 obs. of 1 variable:
#> $ time_open: chr "2019-04-21T00:00:01.000Z"
library(lubridate)
DF$time_open <- ymd_hms(DF$time_open)
str(DF)
#> 'data.frame': 1 obs. of 1 variable:
#> $ time_open: POSIXct, format: "2019-04-21 00:00:01"
DF
#> time_open
#> 1 2019-04-21 00:00:01
DF$time_open <- format(DF$time_open, format = "%X %m.%d.%Y")
str(DF)
#> 'data.frame': 1 obs. of 1 variable:
#> $ time_open: chr "12:00:01 AM 04.21.2019"
DF
#> time_open
#> 1 12:00:01 AM 04.21.2019
Created on 2022-04-22 by the reprex package (v0.2.1)
This topic was automatically closed 21 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.