Home » Php » How to find the next hour of current time with PHP?

How to find the next hour of current time with PHP?

Posted by: admin February 25, 2020 Leave a comment

Questions:

I want to find the next time of the current time.

I always want to find the next hour from the current time, even if the page is refreshed.

<?php 
  $now_time = date('H:i');
?> 

Example Now at: 18:00

I Want Time: 19:00

Example Now at: 18:05

I Want Time: 19:00

Example Now at: 18:59

I Want Time: 19:00

Example Now at: 19:00

I Want Time: 20:00

Example Now at: 19:10

I Want Time: 20:00

How to&Answers:

$next_hour = date(‘h:00’, strtotime(‘+1 hour’));

Answer:

echo strtotime( date('Y-m-d H:00:00', strtotime('next hour')) )