立即获取时间范围

I need to get the range of hour by current time, its means:

If current time is 18:25 i need to make a array (18:00,19:00).

I try to:

$hourFromAut = Date('H'); // Time current
$hourTo += 1;
$hourRange = array($hourFromAut,$hourTo)

But this get out of the range.

Since no one has answered this yet.

As others have mentioned in the comments, this is easier using DateTime() which offers you more control over dates and times.

$currentHour = (new DateTime())->format('H:00');
$nextHour    = (new DateTime('+1 hour'))->format('H:00');
$hourRange   = [$currentHour, $nextHour];

Demo

There's many way to go about this, especially using DateTime() but this should get you started.

I would getdate():

<?php
date_default_timezone_set('America/Vancouver'); // if server is not correct time - change to your timezone of course
$dt = getdate(); $hour = $dt['hours']; $hourRange = [$hour.':00', ($hour+1).':00'];
?>