How to receive a Variable Type DateTime from MYSQL in PHP file

0

Friends, my intention is to receive the value of a type = datetime field from MYSQL in a php file

$sql=mysqli_query($con,"select fecha FROM tabla1 WHERE campo1=1");
  $rw=mysqli_fetch_array($sql);
    $fecha_que_recibo=$rw['fecha'];

The date I want to receive has the following format in the database Year / Month / day / hour / minute / second Example: 2017-08-12 11: 38:05

Here I leave the error that throws me the php date (): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set () function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone

    
asked by David 13.08.2017 в 05:40
source

1 answer

0

You are saying that you have not defined the time zone of your php server. You can edit the file /etc/php/7.0/php.ini, search for the date.timezone entry, uncomment it and assign it the value you need (eg Europe / Madrid). Do not forget after restarting the server so that it takes the changes.

You can also, before calling the date (), make the call to the function indicated, the date_default_timezone_set ('Europe / Madrid'); .

Review link for more information.

Personally, I recommend the first option.

    
answered by 13.08.2017 / 12:51
source