php – “date(): It is not safe to rely on the system’s timezone settings…”

Question:

I took a system to maintain, and when I migrated to another server, it started to give an error in an input with the current date, ex:.

<input type='text' value='<?php echo date("d/m/Y"); ?>'>

Mas está dando o seguinte erro:

WARNING: 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. IN
/XXX/XXXXXX/XXXXXXXXXXX/PAINEL-MASTER.PHP ON
LINE 458

WARNING: 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. IN
/XXX/XXXXXX/XXXXXXXXXXX/PAINEL-MASTER.PHP ON
LINE 458
11/01/2018

Setei no início do PHP:

date_default_timezone_set('America/America/Sao_Paulo');

But from then on I don't know how to set the date (Day/Month/Year) inside the input, I read about what is suggested in WARNING but I didn't solve it.

Answer:

You probably need to put the timezone in a config line in your php.ini . You should have something like this in your php.ini file:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = America/Sao_Paulo
Scroll to Top