Answer the question
In order to leave comments, you need to log in
Mysql php insert into database and getting date back is not correct how to solve?
There are 2 servers 1 under php / http another under the database
Both databases have the same time zone sec per sec.
In the PHP MSK
configs In the Mysql configs
on the server where php insert the date into the table with
set time_zone = '+00:00'
the script itself to understand what and how...
$date = date('Y-m-d H:i:s');
echo "PHP DATE ". $date;
echo "<br>";
$sql = 'INSERT INTO test_date SET `date`=:date';
$id = Yii::$app->db->createCommand($sql,[':date' => $date ])->execute();
$date = Yii::$app->db->createCommand("select date from test_date where id=:id",[':id' => $id ])->queryScalar();
echo "MYSQL DATE ". $date;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question