Danny620 Posted May 19, 2012 Share Posted May 19, 2012 $expires = time() - 2 * 30 * 30 Quote Link to comment https://forums.phpfreaks.com/topic/262773-does-this-mean-30-mins/ Share on other sites More sharing options...
cpd Posted May 19, 2012 Share Posted May 19, 2012 Your question needs to be more in depth. 30 minutes in what? Minutes, seconds, hours? The function time() returns a Unix timestamp (which is in seconds) calculated using the date January 1 1970 00:00:00 GMT as described at http://php.net/time To add 30 minutes to the current time (if that's what you're looking to do) you need to calculate 30 minutes in seconds as your Unix timestamp is in seconds. Whilst this is not compulsory, I would argue its the most logical way of doing it else you'll be converting one timestamp to another form and it gets over complicated. Moreover, if you want an expiration time you shouldn't be subtracting time you should be adding time to generate a time in the future. Therefore the calculation you need (provided you want an expiration Unix timestamp with a period of 30 minutes) is: $expires = time() + (60*30); 60 seconds to a minute and you want 30 minutes worth of seconds added to the current time. Quote Link to comment https://forums.phpfreaks.com/topic/262773-does-this-mean-30-mins/#findComment-1346805 Share on other sites More sharing options...
johnsmith153 Posted May 19, 2012 Share Posted May 19, 2012 Yes, it does mean 30 mins (I'd use brackets though to enclose the calculation). Hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/262773-does-this-mean-30-mins/#findComment-1346873 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.