There's a subtle distinction here that may be throwing you off.
As ?strptime
notes:
for 'strptime' '%OS' will input seconds including fractional seconds.
To emphasize that a bit, %OS
represents the seconds including fractional seconds --- not just the fractional part of the seconds: if the seconds value is 44.234, %OS
or %OS3
represents 44.234, not .234
So the solution is indeed to substitute a .
for that final :
.
Here's one way you might do that:
x <- "2012.01.15 09:00:02:002"
strptime(gsub(":", ".", x), "%Y.%m.%d %H.%M.%OS")