ItSolutionStuff.com

How to Subtract Minutes from DateTime in PHP?

By Hardik Savani • May 14, 2024
PHP

This tutorial will give you example of php subtract minutes from datetime. i explained simply about php subtract minutes from current time. We will use how to subtract minutes from time in php. This article goes in detailed on how to subtract minutes from current time in php.

I will give you very simple example how to sub minutes to date and time in PHP. so let's see both example with output:

Example 1: PHP Subtract Minutes to DateTime

index.php

<?php

$date = "2021-11-01 10:10:05";

$newDate = date('Y-m-d H:i:s', strtotime($date. ' -10 minutes'));

echo $newDate;

?>

Output:

2021-11-01 10:00:05

Example 2: PHP Subtract Minutes to Current DateTime

index.php

<?php

$newDate = date('Y-m-d H:i:s', strtotime(' -10 minutes'));

echo $newDate;

?>

Output:

2021-11-10 06:39:33

i hope it can help you...

Tags: PHP
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Add Seconds to Time in PHP?

Read Now →

PHP Add Minutes to Time Example

Read Now →

PHP Add Hours to Datetime Example

Read Now →

PHP Subtract Year from Date Example

Read Now →

PHP Subtract Month from Date Example

Read Now →

How to Subtract Days to Date in PHP?

Read Now →

How to Add Year to Date in PHP?

Read Now →

How to Add Months to Date in PHP?

Read Now →

How to Add Days to Date in PHP?

Read Now →