manuelgod Posted February 8, 2007 Share Posted February 8, 2007 Hi, I tried looking around but couldn't find a source on how to add days OR months to a date in the following format 2007/01/29 It would be nice if someone could post such a script that will display the future date depending the amount of months OR the number of days the user inputs. So if the user start date is 2007/01/31 and the user type 1 month the script will display 2007/02/01 to compensate for the leap years and months that are less then the one set. Anyone with such a script? Thank you in advance! Link to comment https://forums.phpfreaks.com/topic/37574-number-of-days-or-months/ Share on other sites More sharing options...
KrisNz Posted February 8, 2007 Share Posted February 8, 2007 You cant do it on a string like '2007/01/29', you need to convert it to a timestamp first. $date_ts = strtotime('2007/01/29'); //then say you wanted to add 4 weeks to that date and print it to the user. $one_month_from_now = strtotime("+4 week",$date_ts); echo date("Y/m/d",$one_month_from_now); strtotime is a really cool and powerful function, http://au3.php.net/strtotime Link to comment https://forums.phpfreaks.com/topic/37574-number-of-days-or-months/#findComment-179711 Share on other sites More sharing options...
manuelgod Posted February 9, 2007 Author Share Posted February 9, 2007 Cool! Thanks for the reply ..later ! Link to comment https://forums.phpfreaks.com/topic/37574-number-of-days-or-months/#findComment-180278 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.