There seem to be several time functions out there and I'm not sure which will suit my needs best.
I need to add $months to a time stamp for now().
I need to output a future date $months from now.
Thanks!
Which Time Function To Use
Moderator: General Moderators
Re: Which Time Function To Use
strtotime() converts an English string to a Unix timestamp.
Code: Select all
$months = 5;
$time = strtotime("+{$months} months");
echo date("Y-m-d H:i:s", $time);Re: Which Time Function To Use
NOW() is a MySQL function. If you're doing this in MySQL, use DATE_ADD.JakeJ wrote:I need to add $months to a time stamp for now().
Re: Which Time Function To Use
I thing you need my sql function, so use:
Code: Select all
DATE_ADD( NOW( ) , INTERVAL 1 MONTH );
Re: Which Time Function To Use
That did it for me! Muchas Gracias!tasairis wrote:strtotime() converts an English string to a Unix timestamp.Code: Select all
$months = 5; $time = strtotime("+{$months} months"); echo date("Y-m-d H:i:s", $time);