0

How do I get current timestamp with milliseconds precision?

I tried the option of setting digits.secs=3 but, couldn't get the milliseconds part.

> op<-options(digits.secs=3)
> format(Sys.time(),format="%Y-%m-%d %H:%M:%S.%s")
[1] "2015-01-07 22:44:51.1420650891"
> library(lubridate)
> format(now(),format="%Y-%m-%d %H:%M:%S.%s")
[1] "2015-01-07 22:45:15.1420650915"

I need the milliseconds precision specifically as that is how the rest of the system is set-up.

Cœur
  • 37,241
  • 25
  • 195
  • 267
cogitoergosum
  • 2,309
  • 4
  • 38
  • 62
  • 2
    How about `format(Sys.time(), format="%Y-%m-%d %H:%M:%OS3")` – Matthew Lundberg Jan 07 '15 at 17:25
  • @MatthewLundberg Yes, that worked, thanks ! It also worked with `%3S` for the seconds bit. @Henrik, yes, a possible duplicate - I was too focused on generation than parsing. Sorry! – cogitoergosum Jan 07 '15 at 17:34
  • 2
    @henrik I don't believe that this is actually a duplicate, as the linked question is about parsing text strings and this is formatting timestamps. While these are related, there must be a better question to choose as a duplicate. – Matthew Lundberg Jan 07 '15 at 17:52

0 Answers0