Well I have the following time in a variable:
$x = "10:15";
I have two different questions,
How do I add 30 minutes to this time.
How do I add 1 hour to this time.
Thank you.
Well I have the following time in a variable:
$x = "10:15";
I have two different questions,
How do I add 30 minutes to this time.
How do I add 1 hour to this time.
Thank you.
To add an hour you can do this:
$timestamp = strtotime('10:15') + 60*60;
$dataHora = strftime('%d - %m - %Y, %H:%M', $timestamp); // 24 - 12 - 2016, 11:15
To add 30 mins:
$timestamp = strtotime('10:15') + 60*30;
$dataHora = strftime('%d - %m - %Y, %H:%M', $timestamp); // 24 - 12 - 2016, 10:45
strtotime returns the number of secs
You can see more here about the formatting you want link
It has a simple way that is:
$date = date('Y-m-d H:i', strtotime('+30 minutes'));
echo $date;
To add 1 hour:
$date_1_hora = date('Y-m-d H:i', strtotime('+1 Hours'));
echo $date_1_hora;