in reply to choosing closest date to a given date

working with seconds-since-the-epoch-unix-style may be the fastest and most straight-forward way. As a bonus, future and past are distinguished by the sign of the result of the subtraction of the two dates' epochs.

But you will soon discover that you want to compare dates in different time-zones too. And therefore a module for high-level date construction/parsing/manipulation like DateTime (and its sub-tree) might be more useful to you to use from the start.

If you are only interested in Date rather than Date+Time then Date::Simple has <=> overloaded, which means something like this: if( $dt1 > $dt2 ){ } works fine.

I have used both modules with great satisfaction.