How to get the exact date and time after updating a record?

Asked

Viewed 203 times

0

Whenever I update user data, returns me the wrong time, for example:

I updated the user profile at 16:41, but in my database it appears like this 2019-10-15 16:10:53

I’m using mysql along with phpmyadmin

This is my data update array

date_default_timezone_set('America/Sao_Paulo');
$data = array(
 'updated_at' => date('Y-m-d : H:m:s', time()),
);
  • What is the date and time of the machine the database is on?

  • I set php.ini to America/Sao_paulo format, but it still keeps to the wrong time.

  • Come on. Mysql takes the time and Timezone set on the server and calculates the time difference. First check that the time set on the server is correct.

  • But what computer time is Mysql on? The time is correct?

2 answers

4


Try changing the update date by replacing the minutes (’m') with ('i')

 date_default_timezone_set('America/Sao_Paulo');
$data = array(
 'updated_at' => date('Y-m-d : H:i:s', time()),
);

Put a bullet in it and see what.

1

You are entering the month in place of the minutes. The correct syntax is:

date('Y-m-d H:i:s', time())

Browser other questions tagged

You are not signed in. Login or sign up in order to post.