You might want to use this function instead:
PHP Code:
time(&hour=0, &minute=0, &second=0);
so you would have number of hours as an integer instead of a string, so comparing it to other values would be easier.
PHP Code:
new iHours;
time(iHours);
// iHours now contains number of hours!
// ...
if(iHours >= 22 && iHours < 7)
{
// Nighttime is from 10 PM to 7 AM
}