Note on the code given by cory at lavacube dot net.You will recieve better results by not using floor and using round instead. As you continue increasing to larger amounts of time you will notice that the outputted time is off by large amounts.

The first function modulo() above is the mathematical function which is useful for working on cyclic structures (such as calender computions or trignonometric functions :

- fmod($a, 2*PI) returns a value in [0..2*PI) if $a is positive
- fmod($a, 2*PI) returns a value in [-2*PI..0] if $a is negative
- modulo($a, 2*PI) returns a value always in [0..2*PI) independantly of the sign of $a

If your given a number of seconds and you want to turn it into Days, hours, minutes, and seconds:(this is very useful when using the Unix Time Epoch to find the difference from one time to the other)

For Example:I posted in a bb at one date.. when I post a Unix Time Epoch was marked..Then When I go back and view it again 2 weeks later I generate the Unix Time Epoch for the current time. Then take the current time - the posting time, this gives the number of seconds since the post.Then use the below equations to get days, hours, minutes, and seconds since the post was made:

fmod() does not mirror a calculator's mod function. For example, fmod(.25, .05) will return .05 instead of 0 due to floor(). Using the aforementioned example, you may get 0 by replacing floor() with round() in a custom fmod().