Pieber
Pieber

Reputation: 423

Setting date.timezone in php.ini does not work

Snapshot of the output of phpinfo() function:

enter image description here

As I am trying to install Roundcube which requires to set date.timezone, I would like to set date.timezone by filling the date.timezone field in php.ini.

Server Configuration

What I tried

According to http://php.net/manual/en/timezones.php, I modified the date.timezone field from both /etc/php/7.0/apache2/php.ini and /etc/php/7.0/cli/php.ini with different syntaxes:

date.timezone = Europe/Paris
date.timezone = 'Europe/Paris'
date.timezone = "Europe/Paris"

And I always restarted Apache after any change.

Nothing change in phpinfo, the date.timezone field is always set to "no value" and the first step of the installation of Roundcube, date.timezone is NOT OK.

But when I try:

php -i

I get:

date/time support => enabled
"Olson" Timezone Database Version => 0.system
Timezone Database => internal
Default timezone => Europe/Paris

Directive => Local Value => Master Value
date.default_latitude => 31.7667 => 31.7667
date.default_longitude => 35.2333 => 35.2333
date.sunrise_zenith => 90.583333 => 90.583333
date.sunset_zenith => 90.583333 => 90.583333
date.timezone => Europe/Paris => Europe/Paris

I read many pretty old posts about this type of issue but the different solutions did not work for me. Any idea?

EDIT

According to phpinfo():

Configuration File (php.ini) Path

/etc/php/7.0/apache2

Loaded Configuration File

/etc/php/7.0/apache2/php.ini

Scan this dir for additional .ini files

/etc/php/7.0/apache2/conf.d

Additional .ini files parsed

/etc/php/7.0/apache2/conf.d/10-mysqlnd.ini, /etc/php/7.0/apache2/conf.d/10-opcache.ini, /etc/php/7.0/apache2/conf.d/10-pdo.ini, /etc/php/7.0/apache2/conf.d/15-xml.ini, /etc/php/7.0/apache2/conf.d/20-calendar.ini, /etc/php/7.0/apache2/conf.d/20-ctype.ini, /etc/php/7.0/apache2/conf.d/20-curl.ini, /etc/php/7.0/apache2/conf.d/20-dom.ini, /etc/php/7.0/apache2/conf.d/20-exif.ini, /etc/php/7.0/apache2/conf.d/20-fileinfo.ini, /etc/php/7.0/apache2/conf.d/20-ftp.ini, /etc/php/7.0/apache2/conf.d/20-gd.ini, /etc/php/7.0/apache2/conf.d/20-gettext.ini, /etc/php/7.0/apache2/conf.d/20-iconv.ini, /etc/php/7.0/apache2/conf.d/20-imagick.ini, /etc/php/7.0/apache2/conf.d/20-imap.ini, /etc/php/7.0/apache2/conf.d/20-intl.ini, /etc/php/7.0/apache2/conf.d/20-json.ini, /etc/php/7.0/apache2/conf.d/20-mbstring.ini, /etc/php/7.0/apache2/conf.d/20-mcrypt.ini, /etc/php/7.0/apache2/conf.d/20-memcache.ini, /etc/php/7.0/apache2/conf.d/20-mysqli.ini, /etc/php/7.0/apache2/conf.d/20-pdo_mysql.ini, /etc/php/7.0/apache2/conf.d/20-pdo_sqlite.ini, /etc/php/7.0/apache2/conf.d/20-phar.ini, /etc/php/7.0/apache2/conf.d/20-posix.ini, /etc/php/7.0/apache2/conf.d/20-pspell.ini, /etc/php/7.0/apache2/conf.d/20-readline.ini, /etc/php/7.0/apache2/conf.d/20-recode.ini, /etc/php/7.0/apache2/conf.d/20-shmop.ini, /etc/php/7.0/apache2/conf.d/20-simplexml.ini, /etc/php/7.0/apache2/conf.d/20-snmp.ini, /etc/php/7.0/apache2/conf.d/20-sockets.ini, /etc/php/7.0/apache2/conf.d/20-sqlite3.ini, /etc/php/7.0/apache2/conf.d/20-sysvmsg.ini, /etc/php/7.0/apache2/conf.d/20-sysvsem.ini, /etc/php/7.0/apache2/conf.d/20-sysvshm.ini, /etc/php/7.0/apache2/conf.d/20-tidy.ini, /etc/php/7.0/apache2/conf.d/20-tokenizer.ini, /etc/php/7.0/apache2/conf.d/20-wddx.ini, /etc/php/7.0/apache2/conf.d/20-xmlreader.ini, /etc/php/7.0/apache2/conf.d/20-xmlrpc.ini, /etc/php/7.0/apache2/conf.d/20-xmlwriter.ini, /etc/php/7.0/apache2/conf.d/20-xsl.ini

Upvotes: 6

Views: 14622

Answers (5)

I faced the similar problem problem. 'date.timezone' in php.ini is showin as 'not set' / 'no value' when running php under apache. Checked through phpinfo(). Issue not solved even when apache is restarted. It is solved by restarting php-fpm service ( Fast cgi process manager).

systemctl restart php-fpm

[I am not a native speaker of English. I tried my best to edit the answer after going through the message in my stackoverflow INBOX].

Upvotes: 6

Mike C
Mike C

Reputation: 413

I noticed it was different in two places in my php.ini file for xampp, here:

   [Date]
   ; Defines the default timezone used by the date functions
   ; http://php.net/date.timezone
   date.timezone = "America/Phoenix"```

and here:

; List of headers files to preload, wildcard patterns allowed.
;ffi.preload=
[Syslog]
define_syslog_variables=Off
[Session] 
define_syslog_variables=Off
[Date]
date.timezone=Europe/Berlin```

Note they are different--I have no idea how "Europe/Berlin" got in my php.ini. I noticed this showing up in my php error logs and searched through the whole xampp folder.

Upvotes: 1

Sophie cai
Sophie cai

Reputation: 309

Let me contribute something: I was installing SilverStripe on a VPS and had the exact same problem. I have been searching the answer the whole late afternoon without positive outcome. After all attempts, I removed the ";" in front of

[Date]

; Defines the default timezone used by the date functions

;date.timezone = Europe/London

Here is where I got the answer: https://www.silverstripe.org/community/forums/installing-silverstripe/show/15398?start=8

Hope everyone avoids this trouble

Upvotes: 1

Pieber
Pieber

Reputation: 423

I have found the problem. It was a syntax error in my php.ini file in the error_reporting area.

Upvotes: 1

MackProgramsAlot
MackProgramsAlot

Reputation: 593

php_info() will always indicate the path of the .ini that's being used, ensure this is correct, and aligns with the ini that your are editing.

Upvotes: 0

Related Questions