copy()->startOfDay(); $now = Carbon::now()->startOfDay(); $diff = $startOfEvent->diffInDays($now, false); if ($diff >= 0) { // The first day of the event (diff 0) should be 1. // The seconds day of the event (diff 1) should be 2. // Add one day to the diff. return $diff + 1; } if (config('event_has_day0') && $diff < 0) { // One day before the event (-1 diff) should day 0. // Two days before the event (-2 diff) should be -1. // Add one day to the diff. return $diff + 1; } // This is the remaining case where the diff is negative (before event). // One day before the event (-1 diff) should be day -1. // Two days before the event (-2 diff) should be day -2. // Return as it is. return $diff; } }