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.
GETDATE() should give you the current date:
$sql = "INSERT INTO db-name(col-name) VALUES (GETDATE())";
I solved it using datetime data type for the column-
date_default_timezone_set('Europe/Paris'); //Don't forget this..I had used this..just didn't mention it in the post
$datetime_variable = new DateTime();
$datetime_formatted = date_format($datetime_variable, 'Y-m-d H:i:s');
$sql = "UPDATE table-name SET col-name = '$time_formatted' WHERE ---";
$sql = sqlsrv_query($connection,$sql);
However I am not able to get the perfect datetime. I am getting the next day's date. I am on it! Thanks all for the help! Solved that as well, just need a minor adjustment to the timezone of the computer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With