Using PHP insert current date time in sql server via sqlsrv drivers

Zerocode picture Zerocode · Feb 5, 2015 · Viewed 16.5k times · Source

Till now I have tried

$sql = "INSERT INTO table-name(col-name) values (cureent_timestamp)";

and have set the column data type as datetime , I get some values but no date or time.

Answer

Mureinik picture Mureinik · Feb 5, 2015

GETDATE() should give you the current date:

$sql = "INSERT INTO db-name(col-name) VALUES (GETDATE())";