Fix links for date/time searching on error page

The calculations were wrong if today was the last month, day, hour,
minute or second.  This new code is simpler and more correct.