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 :(

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.