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 Link to comment https://forums.phpfreaks.com/topic/62217-how-to-print-a-date-which-is-after-30-daysby-not-using-any-functions/ 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. Link to comment https://forums.phpfreaks.com/topic/62217-how-to-print-a-date-which-is-after-30-daysby-not-using-any-functions/#findComment-309658 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 Link to comment https://forums.phpfreaks.com/topic/62217-how-to-print-a-date-which-is-after-30-daysby-not-using-any-functions/#findComment-309661 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 Link to comment https://forums.phpfreaks.com/topic/62217-how-to-print-a-date-which-is-after-30-daysby-not-using-any-functions/#findComment-309735 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.