peppericious Posted October 3, 2011 Share Posted October 3, 2011 As far as I can see, this code: $this->_licence_expires = date('Y/m/d', mktime(0, 0, 0, date("m"), date("d")-1, date("Y"))); results in accounts expiring 1 year from today, right? How can I change it so that it will result in expiry 9 months from today? TIA Quote Link to comment https://forums.phpfreaks.com/topic/248320-how-to-make-account-expire-9-months-from-today/ Share on other sites More sharing options...
Buddski Posted October 3, 2011 Share Posted October 3, 2011 From what I can see that code will always create the date for yesterday. If you were to echo it out from todays date (2011/10/03) The result is 2011/10/02 Quote Link to comment https://forums.phpfreaks.com/topic/248320-how-to-make-account-expire-9-months-from-today/#findComment-1275148 Share on other sites More sharing options...
peppericious Posted October 3, 2011 Author Share Posted October 3, 2011 From what I can see that code will always create the date for yesterday. ... oops, sorry. That notwithstanding, however, what replacement code would result in an expiry 9 months from today? Quote Link to comment https://forums.phpfreaks.com/topic/248320-how-to-make-account-expire-9-months-from-today/#findComment-1275165 Share on other sites More sharing options...
Buddski Posted October 3, 2011 Share Posted October 3, 2011 These both should do what you are after date('Y/m/d', strtotime('+9 month')); date('Y/m/d', mktime(0, 0, 0, date("m")+9, date("d"), date("Y"))); Quote Link to comment https://forums.phpfreaks.com/topic/248320-how-to-make-account-expire-9-months-from-today/#findComment-1275174 Share on other sites More sharing options...
peppericious Posted October 3, 2011 Author Share Posted October 3, 2011 These both should do what you are after date('Y/m/d', strtotime('+9 month')); date('Y/m/d', mktime(0, 0, 0, date("m")+9, date("d"), date("Y"))); Greatly appreciated, Buddski, thanks. I'll try each of your solutions. For clarity, I should have specified why I wanted to do this: I'm providing access to academic content so I wanted (classroom licensing) to last for the duration of an 'academic year' (i.e. 9 months). I wanted to avoid licences spilling over into a second academic year as far as possible. Quote Link to comment https://forums.phpfreaks.com/topic/248320-how-to-make-account-expire-9-months-from-today/#findComment-1275183 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.