I’m now inserting a date/time data into my date/time field in the database. I have tried many techniques such as:
$date = date("d M Y");
$date = date("d M Y", mktime());
$date = getdate();
$date = date("d M Y", strtotime('now'));
and also this function: date_default_timezone_set('Asia/Bangkok');
but it still does not get the datetime.
This is my sql statement:
$sql = "INSERT INTO ".TABLE_CONTENT."(`title`, `detail`, `crdate`, `modate`, `crby`, moby, isdel) VALUES('".$title."', '".$detail."', '".$crdate."', '".$modate."', '".$crby."', '".$moby."', $isdel)";
After performing the query I got only the 0000-00-00 00:00:00 in my database.
Any help or suggestion would be very appreciated.
Thanks
Looks like your database fields are set to timestamp, so you’ll have to insert data into the database fields in exactly that format.
So this would work
You could also use the MySQL
NOW(), which would insert the current timestamp into that field, although the timezone would be set to whatever timezone your server is on.example: