3

I want to get subseconds so I use following:

> options(digits.secs=6)
> as.POSIXlt(df1$Global.Time[5]/1000, origin="1970-01-01",  tz="America/Los_Angeles")
[1] "2005-06-15 07:53:42.7 PDT"

Why does the output not contain something like "07:53:42.700000"?

Same problem with POSIXct:

> as.POSIXct(df1$Global.Time[3]/1000, origin="1970-01-01",  tz="America/Los_Angeles")
[1] "2005-06-15 07:53:42.5 PDT"
umair durrani
  • 5,597
  • 8
  • 45
  • 85
  • 1
    Check out Aaron's `myformat.POSIXct` function in [his answer here](http://stackoverflow.com/a/7730759/640595). – Jota May 30 '15 at 22:06

1 Answers1

7

How about this (corrected per Frank's direction):

 d <- as.POSIXct(Sys.time())
 format(d,"%Y-%m-%d %H:%M:%OS6")
 [1] "2015-05-30 18:06:08.693852"
Mike Wise
  • 22,131
  • 8
  • 81
  • 104