Reputation: 133
I am attempting to convert a character date time to a date/time format using strptime. The data is in MDY_HM (1/29/20 3:43pm).
My code currently looks like this:
comp_report_tz$Start_Date_Time <- strptime(comp_report_tz$Start_Date_Time, format = "%m/%d/%y %H:%M %p")
The output for each observation simply shows: "< POSIXlt >"
I don't receive any errors when executing.
Upvotes: 1
Views: 2038
Reputation: 269586
Make the following changes:
%I
for the hour%p
for the am/pm. thus we use this format
as.POSIXct("1/29/20 3:43pm", format = "%m/%d/%y %I:%M%p")
## [1] "2020-01-29 15:43:00 EST"
Upvotes: 4