strptime getting all dates as NA

Hi somebody can help me with this:

I have this char string (date) but i can format with strptime, i get only NA.

date <- "2020-08-05T03:48:49Z" #this is the format of the string , why is in this form T03:48:49Z?

strptime(x = eth_date, format = "%Y-%m-%d %H:%M:%S")

You could use lubridate.


date <- "2020-08-05T03:48:49Z"

[1] "2020-08-05 03:48:49 UTC"

strptime() will work, but you're missing the "T" in the middle and need to call out the timezone:

strptime(x = date, format = "%Y-%m-%dT%H:%M:%S", tz="UTC")

The lubridate approach is nice. That solves a messy strptime thing in some data I use too!

1 Like

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.