Thursday, January 20, 2011

[PHP] Difference betwen tow date

    public function _getDiffInHours( $date ){
        $usDate = str_replace ( "/" , "-" ,$date);
        $now = strtotime("now");
        $nextDate = strtotime ( $usDate );
        if(! is_numeric( $nextDate ) || ! is_numeric( $now ) || $nextDate <  $now ){
            return 0;
        }
        return floor( ($nextDate-$now) / (60*60));
    }

No comments:

Post a Comment

Powered by Blogger.