PHP Code for prorated upgrade from one paid account to another

I’ve been using s2member for years now and I absolutely love it. Best membership plugin by far.

I currently have an “Upgrade” page within our user’s profile which gives users of one paid membership the option to “upgrade” to a higher membership at a prorated fee. The PHP code works great (but only via Paypal currently) but I started noticing the following log errors:

ERROR:
2021/06/06 11:15:57 [error] 5009#0: *10112 FastCGI sent in stderr: “PHP message: PHP Warning: date() expects parameter 2 to be integer, string given in /var/www/html/nginx/wp-content/plugins/ezphp/ezphp.php(80) : eval()'d code on line 40” while reading response header from upstream, client: 20.20.20.20, server: domain.com, request: “GET /upgrades/ HTTP/2.0”, upstream: “fastcgi://127.0.0.1:9000”, host: “domain.com”, referrer: “my-account/”

NEED HELP PLEASE:
I’m not a PHP programmer (although I have been able to modify existing php code by trial and error and a lot of guessing) but I need some help with my upgrade code (as I believe it will break in PHP 7.4 and higher)

CURRENT PHP CODE:

[toggle title="My Available Upgrades"]
		<?php		
		$s2member_auto_eot_time = get_user_field ("s2member_auto_eot_time");
		$current_date = new DateTime(date('Y-m-d'));
		$end_date = new DateTime(date('Y-m-d', $s2member_auto_eot_time));
		$interval = $current_date->diff($end_date);
		$PlusFee = 50.00; // Enter subscription fee for Level 1 membership 
		$PremFee = 80.00; // Enter subscription fee for Level 2 membership
		$PlusDailyRate = .13698; // Enter daily rate based on level 1 subscription fee divided by 365
		$PlusCharges = ((365 - $interval->format('%a')) * $PlusDailyRate);
                $PlusCharges = round($PlusCharges,2); 
		$DaysUsed = (365 - $interval->format('%a'));
                $Credit = (365 - $DaysUsed) * $PlusDailyRate;
                $Credit = round($Credit,2); 
		$PremCharges = $PremFee - $Credit; 
		$PremCharges = round($PremCharges,2); //round off number to 2 decimal points		
		?>

		<?php 
			if (S2MEMBER_CURRENT_USER_ACCESS_LEVEL === 4){ ?>
				Not Applicable: You are a site admin.<br>
			<?php } 
			elseif (S2MEMBER_CURRENT_USER_ACCESS_LEVEL === 2){ ?>
				You are already a Premier member. Thank you for your support!
			<?php } 
			elseif (S2MEMBER_CURRENT_USER_ACCESS_LEVEL === 1){ ?>
				<?php if(S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS >= 0){ ?>
					<?php
						if ($s2member_auto_eot_time = get_user_field ("s2member_auto_eot_time") )
						{
						echo "Your membership is set to expires on " . date('M j, Y', $s2member_auto_eot_time) . ", which means you have been a Plus member for $DaysUsed days (prorated at $$PlusCharges).<br><br>";

                        echo "If you upgrade to Premier today, we will deduct $$Credit off the Premier membership fee.  Your new Premier account would then expire 1 year from today.<br>";

						}
						else { echo "";	}
					 ?>
					 <a href="[s2Member-PayPal-Button level='2' ccaps='' desc='Prorated Upgrade from Plus to Premier membership for one year for $<?php echo esc_attr($PremCharges); ?>' ps='paypal' lc='' cc='USD' dg='0' ns='1' custom='domain.com' ta='0' tp='0' tt='D' ra='<?php echo esc_attr($PremCharges); ?>' rp='1' rt='Y' rr='BN' rrt='' rra='1' accept='paypal,visa,mastercard' accept_via_paypal='paypal,visa,mastercard' image='default' output='url' /]">
					<img src="/images/content/upgrade_premier_button2.gif" border="0" width="230px" height="190px"><p class="extplus">for only $<?php echo esc_attr($PremCharges); ?></p></a><br>					  
				<?php } ?>
			<?php }
			elseif (S2MEMBER_CURRENT_USER_ACCESS_LEVEL === 0){ ?>
					<a href="/plus-options/"><img src="/images/content/upgrade_plus_button.gif" border="0" width="230px" height="190px"></a>
                    <br>
                    <a href="/premier-options/"><img src="/images/content/upgrade_premier_button.gif" border="0" width="230px" height="190px"></a>
			<?php } 	        
		?>
[/toggle]

I know it expects parameter 2 to be integer just don’t know how to do that.

Thanks for any help on this.

P.S. If there is a better way to code this, I’d be interested to hear your thoughts also. Please keep in mind I’m still using the EZPHP plugin.