XAMPP PHP date function time is different from local machine time

我们两清 提交于 2020-02-26 06:22:09

问题


My computer local time is 12-03-2013 4:30pm.

My XAMPP date function prints the time as 12-03-2013 10:49:56.

How can I set the XAMPP server time to display the system time?


回答1:


Go to C:\xampp\php\php.ini, or your custom path where php.ini is, open it.

Look for the following: date.timezone = "Europe/Warsaw". Probably You have different value than my Europe/Warsaw. So search just string: date.timezone.

Change value Europe/Warsaw to the proper value, for example date.timezone = "Asia/Kolkata"

If someone's looking for his location, check valid values http://php.net/manual/en/timezones.php

Don't forget to restart your XAMPP.




回答2:


For others who are confused on what timezone (date.timezone) they should use (just like me a while ago), please refer to this manual from PHP

http://php.net/manual/en/timezones.php

Hope this helps.




回答3:


At your XAMPP you can change the php.ini and search

date.timezone

and change it to your prefer timezone

date.timezone = Asia/Jakarta

That's for XAMPP. And if you can't change the web server time at your remote server, try put this date_default_timezone_set() function at your php. Like this :

<?php date_default_timezone_set('Asia/Jakarta'); ?>



回答4:


You have to define the timezone accordingly

date-default-timezone-set('GMT');

More read here

But I would suggest use mysql now() or curdate() to take the server time.



来源:https://stackoverflow.com/questions/15359451/xampp-php-date-function-time-is-different-from-local-machine-time

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!