Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you convert time stamp that has AM/PM at the end of the string?

Tags:

r

I am trying to convert this time stamp to POSIXct

t1 <- c("19-Jun-13 06.00.00.00 PM")

If I do this:

t1 <- as.POSIXct(t1, format="%d-%b-%y %H:%M:%S")

whould this convert this time stamp right? Does that considder the AM/PM at the end?

like image 392
user1471980 Avatar asked Jun 21 '13 16:06

user1471980


1 Answers

Read ?strptime. %p, which only works with %I, not %H. Your time format is also incorrect. Your times are separated by ".", not ":".

as.POSIXct("19-Jun-13 06.00.00.00 PM", format="%d-%b-%y %I.%M.%OS %p")
like image 104
Joshua Ulrich Avatar answered Sep 28 '22 05:09

Joshua Ulrich