I have a column of times like this:
"2:43::00 PM"
"2:43:01 PM"
"2:43:05 PM"
"2:43:06 PM"
"2:43:07 PM"
I want to go to each of the row and subtract 10 minutes from each of the time such that the new column looks like this:
"2:33::00 PM"
"2:33:01 PM"
"2:33:05 PM"
"2:33:06 PM"
"2:33:07 PM"
I am using
difftime(strptime(data$time[i],format="%H:%M:%S"),strptime("00:10:00",format="%H:%M:%S"))
, but it is not showing correct results.
How can i approach this problem?
Try
format(strptime(str1, format = "%I:%M:%S %p") - 10*60, "%I:%M:%S %p")
#[1] "02:33:00 PM" "02:33:01 PM" "02:33:05 PM" "02:33:06 PM" "02:33:07 PM"
str1 <- c("2:43:00 PM", "2:43:01 PM", "2:43:05 PM", "2:43:06 PM", "2:43:07 PM")