Date calculation

Hello,

I know that today can be calculated like this :

$today = date("F j, Y");

But how can I calculate 1 year after today ?

echo "Today is $today, your subscription is valid until $nextyear";

Anyone know how to calculate $nextyear ?

Thanks
kapotAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RoonaanCommented:
$nextyear = date('F j, Y', strtotime('+1 Years'));

-r-
kapotAuthor Commented:
Thanks, but how can I convert it into MySQL DATETIME format ?
RoonaanCommented:
$nextyear = date('Y-m-d H:i:s', strtotime('+1 Years'));

-r-

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ixtiCommented:
Also you can do it with MySQL functions (if you need it):

mysql> SELECT DATE_ADD(NOW(), INTERVAL 1 YEAR);
           -> '2006-04-18 16:03:00'

or

mysql> SELECT FROM_UNIXTIME(875996580);
           -> '1997-10-04 22:23:00'
mysql> SELECT DATE_ADD(FROM_UNIXTIME(875996580), INTERVAL 1 YEAR);
           -> '1998-10-04 22:23:00'
ixtiCommented:
It's usefull, when you have table like (id, name, subscription_date) and want to select subscription_date and 1 year after it:

SELECT DATE_FORMAT(`subscription_date`, '%M %e, %Y') AS `subscription_start`, DATE_FORMAT(DATE_ADD(`subscription_date`, INTERVAL 1 YEAR), '%M %e, %Y') AS `subscription_expire` FROM `table`;
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.