Sunucu yanlış zaman

4 Cevap

So I am from the UK and have hosting in the US. I contacted my host and said that my server time is set 6 hours behind GMT. They said I need to alter this in my CMS.

How would i go about doing this? Whenever i put now() i am getting the wrong time.

Daha önce görmemiştim, herkes herhangi bir öneri sunabilir?

4 Cevap

PHP kullanarak zaman dilimini değiştirebilirsiniz

putenv("TZ=Europe/London");

veya bir hata üretir eğer:

date_default_timezone_set('Europe/London');

Eğer php.ini erişebilir Alternatif if (belki değil nedeniyle hosting)

date.timezone = "Europe/London"

Yukarıdaki ayarı değiştirin ve Tamam olmalıdır. Yukarıdaki Ek - PHP ile php.ini ayarlayabilirsiniz

ini_set('date.timezone', 'Europe/London');

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


Edit:

Benim acele cevap - sen GMT yerine Europe/London yazabiliyordu

MySQL için - Eğer sorgu zaman dilimini ayarlamak için önce SET time_zone = 'GMT' yürütmek time_zone config docs olabilir.

PHP - yürütmek date_default_timezone_set() using one of the supported timezones olabilir. Ayrıca .htaccess direktifini kullanarak değerini ayarlayabilirsiniz:

php_value date.timezone UTC

Eğer ABD'de sunucu saati ayarlanır içinde yerin önünde kaç saniye çalışmak ve doğru saati almak için zaman damgası bu değer katabilir.

Sunucu New York'ta Örneğin, o zaman bu, Londra saati arkasında 18000 saniyedir. Yani, doğru tarih almak olacaktır: <?php $now = date('d M Y', (time() + 18000)) ?>

Dilimini tanımlamak için DateTime :: setTimeZone kullanın. Dokümantasyon http://www.php.net/manual/en/datetime.settimezone.php içinde