Pythondesigns Posted September 20, 2006 Share Posted September 20, 2006 Hello,I want to work out what the time would be if I was to add a variety of time amounts to it.Basically I want to take the current time using the time() function and add to it x years, x months, x days, x hours and x minutes.Each of thesewill be held in a variable. For example $numdays will hold the number of days to add to the current time.Thanks Link to comment https://forums.phpfreaks.com/topic/21437-work-out-time-by-adding-years-days-hours-etc/ Share on other sites More sharing options...
paul2463 Posted September 20, 2006 Share Posted September 20, 2006 you would be better off using strtotime and date() for what you want they are more flexible than time() for manipulating time and days etc.you could then[code]$now = strtotime("now");$timenow = date("H:i:s", $now); // 17:15:00 i.e. 15 minutes past 5 in the evening$timenew = date("H:i:s", (strtotime("+2 day", $now))); //15 minutes past 5 in the evening two days in the future [/code]read the strtotime manual <a href="http://uk2.php.net/manual/en/function.strtotime.php"> Here </a> and the date manual <a href="http://uk2.php.net/manual/en/function.date.php"> Here </a> for more details. Link to comment https://forums.phpfreaks.com/topic/21437-work-out-time-by-adding-years-days-hours-etc/#findComment-95615 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.