Search code examples
rtimedatetime-formatjulian-date

Julian Day time to military time - R


I want to convert the following JD time format to its intuitively interpretable military format ("%H:%M:%S"):

Julian Day time format

Is there a function in R to do this? Any suggestions on how to convert to the desired military time format ("%H:%M:%S")?


Solution

  • Maybe you want something like this (thanks to @Dave2e):

    your_julian <- c(0.388025231484789, 0.388718518515816, 0.389415509256651, 0.390111689812329, 0.390806828705536, 0.392295023149927)
    your_date <- as.POSIXct(your_julian*24*3600, origin="2022-07-08")
    strftime(your_date, format="%H:%M:%S") 
    #> [1] "11:18:45" "11:19:45" "11:20:45" "11:21:45" "11:22:45" "11:24:54"
    

    Created on 2022-07-08 by the reprex package (v2.0.1)