How to subtract minutes from time in PHP
In this tutorial, we will learn How to subtract minutes from time in PHP. I will explain an easy way to create PHP subtract minutes from the current time. You understand how to subtract minutes from time in PHP. So, let’s discuss how to subtract minutes from the current time in PHP.
Also read: How to subtract hours from the time in PHP
Here, I will provide two examples.
- PHP Subtract Minutes to time.
- PHP Subtract Minutes to Current time.
I will give you a simple example of how to subtract Minutes from time in PHP. Here, create a simple example of subtracting 30 Minutes from the current time in PHP.
PHP Subtract Minutes to time
Also read: How to subtract seconds from time in PHP
Example
<?php
$custom_time = "09:36:40";
$new_time = date('H:i:s', strtotime($custom_time. ' -30 minutes'));
echo $new_time;
?>
Output
09:06:40
PHP Subtract Minutes to Current time
Example
<?php
// current time: 10:36:40
$new_time = date('H:i:s', strtotime(' -30 minutes'));
echo $new_time;
?>
Output
10:06:40