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 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 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! Link to comment https://forums.phpfreaks.com/topic/254671-strtotime-help/#findComment-1305924 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.