php 如何在印度时区获取时间?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32327004/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:54:52  来源:igfitidea点击:

How to get time in Indian Time zone?

phptimetimezone

提问by Kichu

For You tube API we are setting start Schedule time and End time In

对于 You Tube API,我们正在设置开始计划时间和结束时间

"2015-08-28T00:00:00.000Z" 

This format the Z- is representing the zulu (GMT-7) time zone. I need to pass the time with Indian time zone code (GMT+5:30).

这种格式的 Z- 代表祖鲁 (GMT-7) 时区。我需要用印度时区代码(GMT+5:30)打发时间。

What's the code I need to put for Indian timezone representation?

我需要为印度时区表示输入什么代码?

回答by ColinDave

Just set the default time zone to your Local time zone

只需将默认时区设置为您的本地时区

<?php
date_default_timezone_set("Asia/Calcutta");   //India time (GMT+5:30)
echo date('d-m-Y H:i:s');
?>

回答by Kuldeep

for PHP, timezone is

对于 PHP,时区是

'Asia/Kolkata'

'亚洲/加尔各答'

you can set the timezone by date_default_timezone_set('Asia/Kolkata');

您可以通过以下方式设置时区 date_default_timezone_set('Asia/Kolkata');

check PHP: Asia Manualfor other timezones in Asia.

查看PHP: Asia Manual了解亚洲的其他时区。

回答by Sani Kamal

Just set the default time zone to your Local time zone

只需将默认时区设置为您的本地时区

<?php
date_default_timezone_set("Asia/Kolkata");   //India time (GMT+5:30)
echo date('d-m-Y H:i:s');
?>

回答by Venkat Kotra

[PHP]
;
; php.ini file changes
;
; This works too
;date.timezone = Asia/Calcutta
;
date.timezone = Asia/Kolkata

回答by Bhavesh Mahale

Set

date.timezone=Asia/Kolkata

In php.ini file in PHP directory.

在 PHP 目录下的 php.ini 文件中。

Linkfor Asian timezones.

亚洲时区链接