From ?POSIXct
we know that
Class "POSIXct" represents the (signed) number of seconds since the beginning of 1970 (in the UTC time zone) as a numeric vector.
Therefore, I've assumed that to get a POSIXct
value in milliseconds we need to multiply by 1000
Consider the days in December 2015
## generate sequence of days in December 2015
d <- seq(as.POSIXct("2015-12-01"), as.POSIXct("2015-12-31"), by = 60*60*24)
# [1] "2015-12-01 AEDT" "2015-12-02 AEDT"
# ...
# [29] "2015-12-29 AEDT" "2015-12-30 AEDT" "2015-12-31 AEDT"
Converting them to integer
d <- as.integer(d)
We see that each integer is 10
digits
nchar(d)
# [1] 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
When multiplying by 1000 to convert to milliseconds we get
nchar(d * 1000)
# [1] 13 13 13 13 12 13 13 13 13 12 13 13 13 13 12 13 13 13 13 11 13 13 13 13 12 13 13 13 13 12 13
some values are only 11 or 12 digits (whereas I would have thought multiplying a 10-digit number by 1000 would add 3 digits)
Is there an explanation for this that I'm not seeing?
See Question&Answers more detail:os