[thelist] Adding 15 mins to PHP time...

Rick den Haan rick.denhaan at gmail.com
Wed Dec 13 09:51:15 CST 2006


Tris schreef:
> How can I add 15 mins to a date function [in PHP, ed.]?
> (I'm also gonna have to fee different times to the javasript ticker,
> but that'll be easiy once I kno whow to knock off time from um, well,
> time :-p  )
>   
Tris,

When I need to do something like this in PHP, I tend to use a timestamp, 
and add (or deduct) the necessary amount of time in seconds. I.e.:

$now = time();
$earlier = $now - (60 * 15); // 60 seconds * 15 minutes

You can then push $earlier to the date function, or strftime, or your 
choice of magickery to turn it into a date, e.g....

$then = date("Y-m-d H:i:s", $earlier);

...to get a string you can paste into a MySQL-query.

HTH,
Rick.



More information about the thelist mailing list