Swat/SwatDate.php
public static function compare(DateTime $date1, DateTime $date2)
    {
        // Not using getTimestamp() here because it is clamped to the 32-bit
        // signed integer range. Float compaison should be safe here as the
        // number are within the double-precision offered by floats and can
        // be represented exactly.
        $seconds1 = (float) $date1->format('U');
        $seconds2 = (float) $date2->format('U');

        if ($seconds1 > $seconds2) {
            return 1;
        }

        if ($seconds1 < $seconds2) {
            return -1;
        }

        return 0;
    }
public static function compare(DateTime $date1, DateTime $date2)
    {
        // Not using getTimestamp() here because it is clamped to the 32-bit
        // signed integer range. Float compaison should be safe here as the
        // number are within the double-precision offered by floats and can
        // be represented exactly.
        $seconds1 = (float) $date1->format('U');
        $seconds2 = (float) $date2->format('U');

        if ($seconds1 > $seconds2) {
            return 1;
        }

        if ($seconds1 < $seconds2) {
            return -1;
        }

        return 0;
    }
public static function compare ( DateTime $ date1 , DateTime $ date2 ) { // Not using getTimestamp() here because it is clamped to the 32-bit // signed integer range. Float compaison should be safe here as the // number are within the double-precision offered by floats and can // be represented exactly. $ seconds1 = ( float ) $ date1 -> format ( 'U' ) ; $ seconds2 = ( float ) $ date2 -> format ( 'U' ) ; if ( $ seconds1 > $ seconds2 ) { return 1 ; } if ( $ seconds1 < $ seconds2 ) { return - 1 ; } return 0 ; }
Compares two SwatDates

This method is provided for backwards compatibility with PEAR::Date.

@param DateTime $date1 the first date to compare.
@param DateTime $date2 the second date to compare.

@return integer a tri-value where -1 indicates $date1 is before $date2,
0 indicates $date1 is equivalent to $date2 and 1
indicates $date1 is after $date2.
Compares two SwatDates