简体   繁体   中英

SilverStripe installation gives error “date.timezone option in php.ini must be set correctly.” even when timezone is set

I'm trying to get an installation of SilverStripe working, but on the installation page it's giving the error: date.timezone option in php.ini must be set correctly even though the timezone is set to Pacific/Auckland

I had edited my php.ini file to set the time zone, then restarted apache, and it still doesn't work. The relevant lines in php.ini are:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Pacific/Auckland

The server is running Ubuntu on AWS.

Try adding these lines to your mysite/_config.php

// Set the site locale
i18n::set_locale('en_US');
ini_set('date.timezone', 'America/New_York');

Editing a PHP file to run the command phpinfo(), then viewing the result in your browser, shows the timezone information currently configured for PHP. If the php.ini date.timezone setting has worked, the correct timezone should be visible in the phpinfo() output.

Strangely it seems an apache restart wasn't enough to change the PHP date.timezone configuration, as phpinfo() showed that the date.timezone setting was still empty. Rebooting the server got it working though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM