# 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
###### Who is Participating?

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.

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

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

-r-

Experts Exchange Solution brought to you by

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

Commented:
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'
Commented:
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.