How to implement the subtraction of time, say at 21:20 an event will be held and to activate the link at 20:45, well, so as not to write twice and so that it takes one time

Closed due to the fact that the essence of the question is not clear to the participants Alex , Enikeyschik , 0xdb , Jarvis_J , Dmitry Kozlov 4 December '18 at 17:59

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • and to activate the link at 20:45 - what do you mean by that? - Alex

2 answers 2

Two options. Both options subtract 35 minutes.

The first

echo date("H:i", strtotime('-35 minutes',strtotime('21:20'))); 

Second

 $dateTimeMinutesAgo = new DateTime("21:20"); $dateTimeMinutesAgo->sub(new DateInterval('PT35M')); $dateTimeMinutesAgo = $dateTimeMinutesAgo->format("H:i"); echo $dateTimeMinutesAgo; 

    If you understand the essence of the question correctly, do you need to calculate the time 35 minutes before the event?

     echo date("H:i",strtotime('-35 minutes',strtotime('21:20')));