Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in R Programming by (50.2k points)

The below is the character vector:

times <- c("2020-04-15T03:30:05.197Z", "2020-04-15T03:30:05.366Z", "2020-04-15T03:30:05.530Z")

I know that I need to convert it to a lubridate datetime object or a POSIXct object. The following does not work:


            format = "%Y-%m-%d%T%H:%M:%S")

1 Answer

0 votes
by (108k points)

I think that the lubridate's ymd_hms should work in your case. Kindly refer to the following code:



#[1] "2020-04-15 03:30:05.197 UTC" "2020-04-15 03:30:05.366 UTC" 

#    "2020-04-15 03:30:05.529 UTC"

If you are a beginner and wants to know more about R then do check out the following R programming tutorial that will help you in learning R from scratch. 

Browse Categories