'Get time of day as a value between 0 and 1 from system time

I'm unable to find documentation on how to correctly extract the time of day as a value between 0 and 1 from the system clock. Meaning 0 is midnight, 0.25 is 6 AM, 0.5 is midday, 0.75 is 6 PM, 1 is midnight again. I have access to either the Unix time (milliseconds passed since 01-01-1970) or the hour:minute:seconds values independently... either can be used, I wouldn't mind knowing the math for both approaches so the solution is compatible with any scripting language I may use this for.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source