"date(): It is not safe to rely on the system’s Timezone Settings..."

Asked

Viewed 3,796 times

3

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

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

But the following mistake is making:

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/XXXXXXXX/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/XXXXXXXX/PAINEL-MASTER.PHP ON LINE 458
11/01/2018

Set 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 did not solve.

2 answers

5

You probably need to put the time zone on a configuration line in your php.ini. You must have something like this in your file php.ini:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = America/Sao_Paulo
  • But and setting this, as I display in the input the date ?

  • solved, okay, thanks...

  • I believe it is a good solution at the global level of the server. If you have programs that need to change the spindle to run in a specific region, you can set it in PHP via date_default_timezone_set()

4


That one timezone does not exist. The Correct is:

date_default_timezone_set('America/Sao_Paulo');

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

  • But and setting this, as I display in the input the date ?

  • solved, okay...

Browser other questions tagged

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