0

2021-01-10T01:15:00.000Z is a string for the timestamp of 1:15am UTC on 20201/01/10. Currently this is saved as a string, however I need to convert this into a datetime or timestamp type in R. I've tried this

as.POSIXct('2021-01-10T01:15:00.000Z', format="%Y-%m-%d %H:%M:%S")

...and a bunch of other format types, however none work. What is the correct value to pass to 'format' parameter for this to work, or is there a better / different way to do this?

Canovice
  • 9,012
  • 22
  • 93
  • 211
  • 1
    Try using `anytime`, which drastically simplifies the process of converting _things_ into date time objects! – mhovd Jan 11 '21 at 19:09
  • 1
    `as.POSIXct('2021-01-10T01:15:00.000Z',format="%Y-%m-%dT%H:%M:%OS")` https://stackoverflow.com/questions/41165867/r-convert-date-from-character-to-datetime – maydin Jan 11 '21 at 19:15
  • 1
    The pattern you tried doesn't match the string. Bot the time separator `T` and the offset specifier `Z` are missing – Panagiotis Kanavos Jan 11 '21 at 19:15

0 Answers0