I want to get day, month, and year from a date but it doesn't work. I always get an error:
Fatal error: Call to a member function format() on a non-object in printtest.php on line 4
This is my printtest.php code. I got an error. How to fix this? Check live demo here.
<?php
    $dob = $_POST['dob'];
    $date = DateTime::createFromFormat("Y-m-d", '$dob');
    $year1 = $date->format("Y");
    $day1 = $date->format("d");
    $mon3 = $date->format("m");
    echo $year1;
?>
 
     
     
     
    