1

I have Windows tick time in milliseconds like 13228488488553 (which should be 12/03/2020 13:08:08 at 1 or 2s approximately). As Windows clock the origin is 1/1/1601. I would like to see it in a readable date/hour format using everything (i.e. not rounding up to seconds, but up to milliseconds). A perfect example format would be DD/MM/YY HH:MM:SS.MSS

I did not find any package doing it, and I tried manually but I am stuck with roundings and leap years. Does anyone know a package or did already do it with a handmade function?

Pyxel
  • 107
  • 11
  • there is a answer here? https://stackoverflow.com/questions/13998206/r-lubridate-converting-seconds-to-date – FrakTool May 27 '20 at 16:55
  • Thank you, I didn't know that lubridate allowed specifying the origin. I tried putting 13228488488553 but get "420795-02-11 16:42:33 CET". I'm trying to find something in the options. – Pyxel May 27 '20 at 19:10
  • Update: I found the issue, must specify the time in seconds and not milliseconds. Is there an option to specify milliseconds? – Pyxel May 27 '20 at 19:14

1 Answers1

3

Here's an approach with as.POSIXct from base R:

format(as.POSIXct(ticktime/1000,
                  origin = "1601-01-01", tz = "UTC"),
       format = "%d/%m/%Y %H:%M:%OS3")
#[1] "12/03/2020 12:08:08.552"

Edit: Perhaps this is your timezone:

format(as.POSIXct(ticktime/1000,
                  origin = "1601-01-01", tz = "CET"),
       format = "%d/%m/%Y %H:%M:%OS3")
#[1] "12/03/2020 13:08:08.552"
Ian Campbell
  • 23,484
  • 14
  • 36
  • 57