为什么我的时间功能不正常

时间:2021-06-13 15:48:42

today date is correct but time i get time 30 minute ahead for sample at now India time is 10:30 and i got the 11:00 pm

今天的日期是正确的,但是我现在有时间提前30分钟的样品现在印度时间是10:30,我得到了晚上11点

date is working but why time is wrong.

日期有效,但为什么时间不对。

<?php
date_default_timezone_set("Asia/Calcutta");
$dates = date('Y-m-d h:i:s', time());
echo $dates;
?>

2 个解决方案

#1


1  

You don't want to give a timestamp

你不想给时间戳

Try this

$dates = date('Y-m-d h:i:s');

#2


0  

Possible causes -

可能的原因 -

  1. Your local computer clock is set wrong
  2. 您的本地计算机时钟设置错误

  3. You have an out-of-date timezone definition file that incorrectly defines Asia/Calcutta, or does not define it at all.
  4. 您有一个过时的时区定义文件错误地定义亚洲/加尔各答,或根本没有定义它。

I have run this successfully here for your timezone (Linux RHEL6, package tzdata-2011d-1.el6.noarch )

我在这里成功运行了你的时区(Linux RHEL6,包tzdata-2011d-1.el6.noarch)

#1


1  

You don't want to give a timestamp

你不想给时间戳

Try this

$dates = date('Y-m-d h:i:s');

#2


0  

Possible causes -

可能的原因 -

  1. Your local computer clock is set wrong
  2. 您的本地计算机时钟设置错误

  3. You have an out-of-date timezone definition file that incorrectly defines Asia/Calcutta, or does not define it at all.
  4. 您有一个过时的时区定义文件错误地定义亚洲/加尔各答,或根本没有定义它。

I have run this successfully here for your timezone (Linux RHEL6, package tzdata-2011d-1.el6.noarch )

我在这里成功运行了你的时区(Linux RHEL6,包tzdata-2011d-1.el6.noarch)