antonyjohn Posted July 28, 2007 Share Posted July 28, 2007 hai friends, i need to do a program in php to calculate the expiry date which is after 30 days...from the current date.. by not using functions.pure php coding plzzzzzzzzzzzzzz help Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 28, 2007 Share Posted July 28, 2007 http://ca.php.net/manual/en/function.strtotime.php There's how. Read the user notes to see how to apply it in various way. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 28, 2007 Share Posted July 28, 2007 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 Quote Link to comment Share on other sites More sharing options...
Barand Posted July 28, 2007 Share Posted July 28, 2007 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.