<?php
         $date = new datetime;
        echo $date->format('m-d-y');
 ?>
Can someone see something I can't? I keep getting unexpected $date on the 2 line. (I'm very new when it comes to php. Any help appreciated.)
<?php
         $date = new datetime;
        echo $date->format('m-d-y');
 ?>
Can someone see something I can't? I keep getting unexpected $date on the 2 line. (I'm very new when it comes to php. Any help appreciated.)
When using the Datetime class you need to instantiate your object using $date = new DateTime(); and then to display the date use echo $date->format('Y-m-d'); to display the date on the page (Y-m-d just being a stand in for the date format got need).
Code
$date = new DateTime();
echo $date->format('Y-m-d');
 
    
    check the case of your = new datetime. I think it should be
 $date = new DateTime();
reference
 
    
    <?php 
    $date = new DateTime();
    echo date_format($date,"m-d-y");
?>
Well you can use this. PHP date_format function.
