Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

given date( ' H:i:s ' ), how do I set variable to 15 minutes prior? 2

Status
Not open for further replies.

casabella

Programmer
Aug 30, 2007
59
US
I need the algorithm to do time math. I need to run a query against entries time stamped 15 minutes ago or earlier. I am stuck getting the time stamp to work.

I tried this:

Code:
$a = date('H:i:s');
$b = '00:15:00';
$c = $a - $b;
echo $a . '<br />';
echo $b . '<br />';
echo $c . '<br />';

and I am getting:

23:17:00
00:15:00
23

I am expecting

23:17:00
00:15:00
23:02:00

Thank you all in advance for your assistance!


Jose
 
to get a time 15 minutes prior to now

Code:
echo date("h:i:s", strtotime('-15 minutes'));
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top