Revision: 20803
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 25, 2009 00:37 by bachya
Initial Code
static public function timeIntervals($start_time, $end_time, $interval) { $start_formatted = strtotime($start_time); $end_formatted = strtotime($end_time); $interval = $interval * 60; $times = array(); for ($i = $start_formatted; $i < ($end_formatted); $i += $interval) { $seconds = $i - strtotime(date('Y-m-d')); $times[$seconds] = date('g:i a', $i); } return $times; }
Initial URL
Initial Description
This function takes a start time, an end time, and an interval ("step size"). It returns an array of times separated by that interval between the start time and end time (similar to what Google Calendar does). The keys of the array are the number of seconds between their times and the start time.
Initial Title
Time Ranges Array
Initial Tags
php
Initial Language
PHP