How to separate time?

I have two different time in the database table like as start time and end time. I need to separate the time in certain interval of 15 min or 30 mins or 1 hour interval.
Let say for an example, the start time and end time are 1.00 and 2.30 respectively  and the time is separating with  15 mins interval such 1.00-1.15, 1.15-1.30, 1.30-1.45, 1.45-2.00, 2.00-2.15 and 2.15-2.30
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
where do you want to do this?
Server side --> PHP ?
Client side --> JavaScript ?

Ray PaseurCommented:
Time is a continuum.  If you have 1:00 and 1:15, then 1:50 and 1:30 you have got a conundrum.  Which time band does 1:15 really belong to?  It's part of two of the time bands.  Probably what you want is 1:00:00 and1:14:59, then 1:15:00 and 1:29:59, right?

Ways of working with PHP dates and times are spelled out in these articles:



Also, can you please tell us how JavaScript is involved?  And if you can show us the database table definitions we might have some ideas that could help with that part, too.
Ray PaseurCommented:
See if this makes sense.  It still has the issue of an overlap of the time bands, it at least shows how to get the intervals.  Comments include links to the relevant man pages.

Class TimeRange
    public $times = [];
    public function __Construct($alpha, $omega, $intvl)
        $this->alpha = new DateTime($alpha);
        $this->omega = new DateTime($omega);
        $this->intvl = new DateInterval($intvl);

        $this->times[] = $this->alpha->format('c');
        while ($this->alpha <= $this->omega)
            $this->times[] = $this->alpha->format('c');
    public function getIntervals()
        return $this->times;

$a = 'Today 1:00pm';
$z = 'Today 2:30pm';
$i = 'PT15M';
$t = new TimeRange($a, $z, $i);
var_dump( $t->getIntervals() );

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.