<?php session_start(); ?>
<?php $dob = $_SESSION['dob']; ?>
<html>
<head> </head>
<body> Age:<?php $from = new DateTime($dob); $to = new DateTime('today'); echo $from->diff($to)->y; ?>
</body>
</html>
You didnt start the session on that page.
And I changed new DateTime(‘$dob’) to new DateTime($dob) because is variable.
0
solved I want to print age in my bill from dob. dob is stored in $_SESSION but its not printing the age in html page