As of May 31, 2023, we have updated our Code of Conduct.
1 of 3

Problems in saving time on mysql as data

I want to save date and time on my mysql database and then want to show them in my webpage's comment box. But writing the following code, my database saving time as 00:00:00 at 00:00 and in the comment box, showing as usually same thing.

protected function commenting_date_time(){ $timestamp=time(); return strftime("%m/ %d/ %y at %H:%M %p", $timestamp); }

public function create_comment(){

global $database;

    $author=$_POST["author"];
$created= $this-> Commenting_date_time();
$bidy= $_POST["bidy"];
    
$query= "INSERT INTO comment (";
$query.=" author, created, bidy ";
$query.=" ) VALUES ( ";
$query.=" '{$author}', '{$created}', '{$bidy}'";
$query.= " )";
$insert_query=mysqli_query($database-> connection, $query);
$database-> ensure($insert_query);
return $insert_query;

}