Skip to content

Instantly share code, notes, and snippets.

@mass6
Created January 4, 2020 10:27
Show Gist options
  • Save mass6/1a6da6114de1c83a2b6dd04af7fdfc57 to your computer and use it in GitHub Desktop.
Save mass6/1a6da6114de1c83a2b6dd04af7fdfc57 to your computer and use it in GitHub Desktop.
Get start time rounded up to next 5 minutes
$currentMinute = Carbon::parse($userStartTime)->startOfMinute();
$diff = (int) $this->roundUpToAny($currentMinute->minute, 5) - $currentMinute->minute; // 50
$additionalMinutes = (integer) $this->roundUpToAny(mt_rand(120, 360), 5);
$start_time = $currentMinute->addMinutes($diff + $additionalMinutes);
dd($start_time);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment