Home  >  Q&A  >  body text

php7.1.4时区设置无效怎么办?

Mac升级PHP到7.1.4后,配置php.ini文件中date.timezone = PRC并重启apache后显示时间仍为欧洲时间,问:该版本时区设置如何生效?

如:

目前时间其实为:2017年05月09日下午1:04:15;正好差8小时。
高洛峰高洛峰2736 days ago1639

reply all(3)I'll reply

  • PHPz

    PHPz2017-05-16 13:02:30

    It has nothing to do with PHP 7.1. It has been like this since 5.1;
    I tested it specifically after you just said it
    Default timezone The default is UTC;
    phpinfo output must be UTC;

    Please make sure you are indeed modifying the current version of php.ini

    Open PHPini ctrl+g line 925 and modify it to:
    date.timezone = "PRC";

    Or set it globally

    date_default_timezone_set('PRC');

    echo date('Y-m-d H:i:s');
                              
    

    Running environment 7.0.24

    by liberxue

    reply
    0
  • PHPz

    PHPz2017-05-16 13:02:30

    Make sure the modified configuration file php.ini is the path displayed by phpinfo? There are also modifications that require restarting apache

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 13:02:30

    • List items

    The php.ini path is definitely correct, but it is invalid after modification.

    • List items

    Use: date_default_timezone_set('PRC') can take effect, but it must be set every time.


    Running version: PHP7.1.4

    reply
    0
  • Cancelreply