How to change the time in apache server so it matches the computer's time (PHP)?

前端 未结 4 1001
盖世英雄少女心
盖世英雄少女心 2020-12-10 11:39

In my particular case, both the server and the client are the same computer, I\'m on localhost. When i echo out the date from the date() function, it displays a totally wron

相关标签:
4条回答
  • 2020-12-10 12:12

    This can be changed in the php.ini:

    • If using xampp, open xampp/php/php.ini.
    • Look for the line date.timezone=Europe/Berlin and change it to your timezone.
      In my case I changed to date.timezone=Africa/Nairobi.
    • Save and restart apache.
    0 讨论(0)
  • 2020-12-10 12:13

    I believe you are looking for: date_default_timezone_set ( string $timezone_identifier )

    Link

    You can also set this in your php.ini config.

    0 讨论(0)
  • 2020-12-10 12:16

    Open the php.ini under /etc/php.ini .

    Uncomment this line and add your continent and the main city. Here is an example which works for Germany (Deutschland).

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

    See the website http://php.net/manual/de/timezones.php for all timezones in German.

    Save the file php.ini. And restart the apache. Mageia LINUX uses this:

    systemctl restart httpd.service
    
    0 讨论(0)
  • 2020-12-10 12:25

    You need to do this in your php.ini file. I am on windows and run WAMP so my php.ini location is at: c:/wamp/bin/apache/Apache2.2.21/bin/

    You then open that file and the default is set to: date.timezone = UTC You would change this value for whatever timezone you want...

    For a full list of timezones supported, you can visit: http://php.net/manual/en/timezones.php

    0 讨论(0)
提交回复
热议问题