"date (): It is not safe to rely on the system's timezone settings ..."

2

I took a system to perform maintenance, and when migrating to another server, started to give an error in an input with the current date, eg.

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

But you are giving the following error:

  

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

Sete at the beginning of PHP:

date_default_timezone_set('America/America/Sao_Paulo');

But from there I do not know how to set the date (Day / Month / Year) within the input, I read about what is suggested in WARNING but I did not solve it.

    
asked by anonymous 11.01.2018 / 14:02

2 answers

3

This timezone does not exist. The correct one is:

date_default_timezone_set('America/Sao_Paulo');

You can also get the list of timezones with the function DateTimeZone :: listIdentifiers

    
11.01.2018 / 14:10
3

You probably need to put the time zone in a configuration line on 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
    
11.01.2018 / 14:11