Skip to content

Instantly share code, notes, and snippets.

@shelane
Created July 7, 2023 02:54
Show Gist options
  • Save shelane/731d4d129e632f89c673b8bc4257f956 to your computer and use it in GitHub Desktop.
Save shelane/731d4d129e632f89c673b8bc4257f956 to your computer and use it in GitHub Desktop.
generate times by half hour increments
<?php
// This should replace the DisplayPracticeTimes function.
$startTime = strtotime('08:00');
$endTime = strtotime('21:00');
$increment = 30 * 60; // 30 minutes in seconds
$times = array();
$current = $startTime;
while ($current <= $endTime) {
$time = date('H:i', $current);
$times[] = $time;
$current += $increment;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment