How to get milliseconds using as.POSIXct or as.POSIXlt in r?

I want to get subseconds, so I use the 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 doesn't the output 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"

      

+3


source to share


1 answer


How about this (fixed in Frank's direction):



 d <- as.POSIXct(Sys.time())
 format(d,"%Y-%m-%d %H:%M:%OS6")
 [1] "2015-05-30 18:06:08.693852"

      

+5


source







All Articles