bootes Posted January 9, 2012 Share Posted January 9, 2012 First time posting code and very new to php aka learning as I go... The below code works as shown, but in the 'else' clause, I'd like to replace the +4 with a variable. How to do this? I've tried, $renewaldate = strtotime($subscriptiondate); $sft = "' +" . $duesmultiplier . " year'"; $next_year = date('Y-m-d',strtotime($sft,$renewaldate)); but this doesn't return what I expect. Perhaps this can't be done using this technique? if($n == 0) { $renewaldate = strtotime($subscriptiondate); $next_year = date('Y-m-d',strtotime('next year',$renewaldate)); echo $next_year; } else { $renewaldate = strtotime($subscriptiondate); $next_year = date('Y-m-d',strtotime('+4 year',$renewaldate)); echo $next_year; } Thank you Quote Link to comment https://forums.phpfreaks.com/topic/254671-strtotime-help/ Share on other sites More sharing options...
Muddy_Funster Posted January 9, 2012 Share Posted January 9, 2012 else { $year_var = '4'; $renewaldate = strtotime($subscriptiondate); $next_year = date('Y-m-d',strtotime( "+$year_var year",$renewaldate)); echo $next_year; } should do it - remember to change to double quotes Quote Link to comment https://forums.phpfreaks.com/topic/254671-strtotime-help/#findComment-1305909 Share on other sites More sharing options...
bootes Posted January 9, 2012 Author Share Posted January 9, 2012 Thank you....that works! Quote Link to comment https://forums.phpfreaks.com/topic/254671-strtotime-help/#findComment-1305924 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.