macworthy
macworthy

Reputation: 95

Converting date to readable format in R

I am trying to convert a date format in my dataset to something readable by R. My idea was to use the strftime function:

time = strftime("Tue Jan 01 19:28:39 EST 2013", format="%a %b %d %H:%M:%S")

But it resulted in the following error:

Error in as.POSIXlt.character(x, tz = tz) : 
character string is not in a standard unambiguous format

How might I solve this?

Upvotes: 0

Views: 817

Answers (2)

tchakravarty
tchakravarty

Reputation: 10984

Use as.POSIXct instead:

time = as.POSIXct("Tue Jan 01 19:28:39 EST 2013", format="%a %b %d %H:%M:%S EST %Y")

The same format mask should technically work with strftime as well, but did not work on my system. YMMV.

Upvotes: 1

Akash Goyal
Akash Goyal

Reputation: 41

ParsedDate <- strptime("Tue Jan 01 19:28:39 EST 2013" ,"%a %b %d %H:%M:%S EST %Y")

Upvotes: 0

Related Questions