0

在php中我设置了以下

 date_default_timezone_set('Asia/Kolkata');

但它没有显示准​​确的时间。

date_default_timezone_set('亚洲/加尔各答');

这是我的网站http://www.adsnjobs.com/的链接

在这里,我通过使用回显时区和当前日期时间

echo date_default_timezone_get() . date('Y-m-d h:i:s a');
4

1 回答 1

0

First, you should use the newer DateTime class, just as good practice:

$date = new DateTime(null, new DateTimeZone('Asia/Kolkata'));
echo $date->format('Y-m-d h:i:s a');

Second, have you tested whether the issue is with your server clock, not the IST time zone? It looks about 10 minutes off to me. Try this:

$date = new DateTime(null, new DateTimeZone('Asia/Kolkata'));
echo $date->format('Y-m-d h:i:s a :: T');

$date->setTimezone(new DateTimeZone('Etc/UTC'));
echo $date->format('Y-m-d h:i:s a :: T');

This will show you the date in UTC and in IST so you can see if there is a 5:30 offset. If there is, it's your server clock.

于 2013-09-12T08:53:21.493 回答