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 Quote Link to comment 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. 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.