public static function secondsSinceMidnightStr($time)
    {
        $time_a = explode(':', $time);

        switch (count($time_a)) {
            case 0:
            case 1:
                return null;

            case 2:
                // Add seconds
                $time_a[] = 0;
                break;

            case 3:
                break;

            default:
                return null;
        }

        return self::secondsSinceMidnight((int) $time_a[0], (int) $time_a[1], (int) $time_a[2]);
    }
public static function secondsSinceMidnightStr($time)
    {
        $time_a = explode(':', $time);

        switch (count($time_a)) {
            case 0:
            case 1:
                return null;

            case 2:
                // Add seconds
                $time_a[] = 0;
                break;

            case 3:
                break;

            default:
                return null;
        }

        return self::secondsSinceMidnight((int) $time_a[0], (int) $time_a[1], (int) $time_a[2]);
    }
public static function secondsSinceMidnightStr ( $ time ) { $ time_a = explode ( ':' , $ time ) ; switch ( count ( $ time_a ) ) { case 0 : case 1 : return null ; case 2 : // Add seconds $ time_a [ ] = 0 ; break ; case 3 : break ; default : return null ; } return self :: secondsSinceMidnight ( ( int ) $ time_a [ 0 ] , ( int ) $ time_a [ 1 ] , ( int ) $ time_a [ 2 ] ) ; }
Return number of seconds since midnight.

@param string $time The time in format: HH:MM:SS or HH:MM

@return int|null Returns null on error
Return number of seconds since midnight .