Jump to content

how to print a date which is after 30 days.by not using any functions


antonyjohn

Recommended Posts

Use strtotime with "+30 days" as its value to get the timestamp in 30days in the future and then use the date to convert the timestamp into a human readable date:

$expire = date("d M Y H:i:s", strtotime("+30 Days"));

echo '<b>Today: </b>' . date("d M Y H:i:s");

echo '<br /><br />';

echo '<b>Expire: </b>' . $expire;

 

EDIT: Beaten to :(

But the question stated "No functions".

 

You are going to need to work out if it's a leap year or not and create an array of number of days in each month and an array of months.

 

Use that to calc the date when 30 days added. Also you have to allow for the 30 days going into the following year.

 

So if current date is Dec 12 2007, adding 30 days gives Dec 42 2007 which is Jan 11 2008

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.