In this post i will share how to add minutes to time in PHP. This example will help you php add minutes to time. You are searching for method to add minutes to time in PHP. In this post, we have provided simple multiple example, which will be very useful to you. We often need to add minutes when working with php so we will share with other artisan.
I will give you very simple and attractive example how to add minutes to datetime in PHP. Let’ see example below.
Read also: How to get month name from date in PHP?
PHP add minutes to time example
If you want to add minutes to a time using strtotime(). In PHP, you can pass a time string with a modification directly to the function.
Example 1: PHP add minutes to time
<?php
$time = "09:09:06";
$newTime = date("H:i:s", strtotime($time. " +10 minutes"));
echo $newTime;
?>
Output:
09:19:06
Example 2: PHP add minutes to current DateTime
<?php
$newTime = date("H:i:s", strtotime($time. " +10 minutes"));
echo $newTime; /* Output: Add 10 minute current time */
?>
Example 3: PHP add minute strtotime() method
For this, you can use the strtotime() method.
Syntax:
$variable_name = strtotime("timeValue + addMinuteValue");
Let’see PHP code is as follows.
<?php
$addMinutes = strtotime("2022-12-08 09:09:06 + 5 minute");
echo date("Y-m-d H:i:s", $addMinutes);
?>
Output:
2022-12-08 09:14:06
I hope this tutorial help you.