Testadmin
Testadmin

Reputation: 2898

How to find the next expiration date in Php

In my Php project, i want to find out the expiration date ( eg,today is my joining date then my expiry date is the next month ie validity is 1 month)

What is the best way to do this.

Upvotes: 1

Views: 2597

Answers (2)

Kumar
Kumar

Reputation: 5147

you will need to look at http://au.php.net/manual/en/function.date.php, look at the examples.

Upvotes: 1

thedev
thedev

Reputation: 2906

How about this ?

http://php.net/manual/en/function.strtotime.php

$date = date("Y-m-d");// current date

$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 day");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +2 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 month");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +30 days")

Upvotes: 2

Related Questions