I want to save a datetime from PHP into my database, but I cannot. The datetime value in the database is always set as 0000-00-00 00:00:00
. What am I doing wrong?
My code:
$today = new DateTime();
$dt = $today->format('Y-m-d H:i:s');
$sql = "UPDATE wp_posts SET post_date = $dt, post_date_gmt = $dt WHERE ID = $id";