I have a problem with dates in PHP

I want to offer a free subscription to a website which will never expire.
I decided to define an expiry date

// Define an expiry date for a free subscription|

$free_sub = 9999-12-31 23:59:59;
$free = new DateTime($free_sub);

here is the folowing swich code :

//Now, add subscription perion to calculated expiry date
switch ($period) {
  case "w":
	// 1 week subscription
    $expr_date->modify('+7 days');
    break;
  case "m":
	// 1 month subscription
    $expr_date->modify('+1 month');
    break;
  case "y":
    // 1 year subscription
    $expr_date->modify('+1 year');
	break;
  case "f":
    // Free basic subscription
  $expr_date = $free;
  var_dump($free);
  exit();
    break;
    
  default:
    echo "No subscription period selected";
} // End switch

And here is a screenshot of the result:

What is the correct way to define this expiry date ?

At a minimum, you need quotes around your expiry date:

$free_sub = "9999-12-31 23:59:59";

Also its probably not going to like 9999 as a year, because most systems run on a 32-bit time_t, which would limit a DateTime to… somewhere in 2038, IIRC?

Maybe it would be better not to try and do longform date calculations, and just add to the subscription-checking code to ignore basic subscribers?