(After I read
tachyon's post again, I thought I should add this comment. i should not second guess his thought too much, and simplify his thought. Any way, I still leave this post here, as some sort of helper to his post.)
The $begin - $end approach would not work, assume that we get both from a function like time().
The problem is that, for time(), after it steps over the biggest positive integer, it would go directly to the smallest negative integer, i.e. the negative integer with the biggest absolute value.
For example, if $begin is 2038-01-18-20:14:06, and $end is 2038-01-18-20:14:07, although there is only 1 second difference, by calling time(), and do $begin - $end, you will get:
2 ** 31 - 1 - (- 2 ** 31) = 2 ** 32 - 1