Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Subtract Minutes

Tags:

php

I want to send a reminder email.I don't want to use cron on Linux/Unix/BSD box or Scheduled Tasks on Windows.

I'm trying to subtract 15 minutes from the current time.

here is my code so far (doesn't work):

$days   = date("j",time()); $months = date("n",time()); $years  = date("Y",time()); $hours  = date("G",time()); $mins   = (date("i",time())); $secs   = date("s",time()); $mins   = $mins-15; 
like image 567
user2536185 Avatar asked Jul 18 '13 08:07

user2536185


People also ask

How do I subtract minutes in Excel?

To subtract time, type in =B2-B1, and it'll return the elapsed time. The answer is displayed as an AM time, so to change that, right click and select Format Cells and change it to h:mm. It'll return the answer in time format (7:35, or 7 hours and 35 minutes).

How do you calculate time difference?

Calculate the duration between two times The goal is to subtract the starting time from the ending time under the correct conditions. If the times are not already in 24-hour time, convert them to 24-hour time. AM hours are the same in both 12-hour and 24-hour time.


1 Answers

To subtract 15 minutes from the current time, you can use strtotime():

$newTime = strtotime('-15 minutes'); echo date('Y-m-d H:i:s', $newTime); 
like image 99
MrCode Avatar answered Sep 30 '22 07:09

MrCode