Handy for dark mode etc…

    $now       = time();
    $longitude = 52.27026;
    $latitude  = -1.89188;

    $sun    = date_sun_info ( $now, $longitude, $latitude);
    $light  = $sun['civil_twilight_begin'];
    $dark   = $sun['civil_twilight_end'];

    if (($now > $light && $now < $dark)) {
      
      // It's daytime

    } else {
      
      // It's nighttime

    }