I have a piece of PHP that is trying to do this:
1) given a string like “h m s” (where h=hr, m=min, s=sec)
2) Add the time from 1) to time()
3) format the result to look like “y-mth-d-h-min-s”
So say the time is now 01-01-2011 1am, I want it to add “10 0 0”, which should give me 01-01-2011 11am, but for some reason at the moment, it does seem to add the string, but it’s not accurate.
This is the code I’m using:
$values_arr['regx_expdate'] = date("Y-m-d H:i:s", time()+$values_arr['regx_expdate']);
where $values_arr[‘regx_expdate’] is the string in the format “h m s”, eg. “10 0 0”.
The main question is how would time() know if “10 0 0” is actually 10hrs 0min 0min, and not 10days 0hr 0min??
Easiest method I can think of is to extract each token from
$values_arr['regx_expdate'], add up the seconds and simple add it totime().For example