There is a post that shows how use lubridate
to go from time to seconds since midnight. How about going from seconds since midnight to time of day?
So, instead of using 06:52:32 to get 24752.05, how do I use 24752.05 to get 06:52:32?
There are 24 hrs in a day. So there are 2460 mins in a day. ( 1hr=60 mins) So there are 246060 seconds in a day. (1 min = 60 seconds) Therefore 86,400 seconds in a day.
Get Current Time in PythonUse the time. time() function to get the current time in seconds since the epoch as a floating-point number. This method returns the current timestamp in a floating-point number that represents the number of seconds since Jan 1, 1970, 00:00:00. It returns the current time in seconds.
What is epoch time? The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).
Use as.POSIXct()
on the sum of the midnight timestamp and your offset, possibly adjusting by setting TZ.
In my default time zone:
R> as.POSIXct(trunc(Sys.time(), units="days") + 24752.05)
[1] "2013-01-16 06:52:32.04 CST"
R>
Note that the answer (just like the preceding question) can be solved just fine in base R, persistent rumors that every time question has to involve lubridate not withstanding.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With