印度的日期和时间在PHP

Muk*_*Agr 5 php date

伙计们我想用PHP获得正确的印度时间和日期

我试过这段代码:

$date = date("d/m/Y");
$date1 =  date("H:i a");

if(function_exists('date_default_timezone_set'))
{
    date_default_timezone_set("Asia/Kolkata");
}

echo $date;
echo $date1;
Run Code Online (Sandbox Code Playgroud)

但我没有得到正确的时间.我的时间已经4.30很晚了几个小时.我的代码中有错误吗?

Kev*_*vin 6

在使用任何日期函数之前先放置时区声明:

// set the timezone first
if(function_exists('date_default_timezone_set')) {
    date_default_timezone_set("Asia/Kolkata");
}

// then use the date functions, not the other way around
$date = date("d/m/Y");
$date1 =  date("H:i a");

echo $date . '<br/>';
echo $date1;
Run Code Online (Sandbox Code Playgroud)