9952 explained code solutions for 126 technologies

php-pdoBind current datetime with PHP PDO

$st = $pdo->prepare('INSERT INTO test SET name = :name, created_at = :now');
$st->execute([':name' => 'Donald', ':now' => date('Y-m-d H:i:s')]);ctrl + c

prepare given query to execute


run query on the server


datetime column to be populated


placeholder for current date/time value

date('Y-m-d H:i:s')

will return current time in YYYY-MM-DD HH:mm:ss format