How to insert the current timestamp into MySQL database using a PHP insert query
This format is used to get current timestamp and stored in mysql
$date = date("Y-m-d H:i:s");
$update_query = "UPDATE db.tablename SET insert_time=".$date." WHERE username='" .$somename . "'";
What error message are you getting?
I'd guess your actual error is because your php variable isn't wrapped in quotes. Try this
$update_query = "UPDATE db.tablename SET insert_time=now() WHERE username='" .$somename . "'";
Your usage of now() is correct. However, you need to use one type of quotes around the entire query and another around the values.
You can modify your query to use double quotes at the beginning and end, and single quotes around $somename
:
$update_query = "UPDATE db.tablename SET insert_time=now() WHERE username='$somename'";