如何使用马来西亚时区的 php 代码显示时间

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19583592/
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 19:44:46  来源:igfitidea点击:

how to I can show time with php code with Malaysia timezone

php

提问by Dieba

I need to show now time on my site in my city Batu Pahat/Malaysia I'm using this code:

我现在需要在我所在城市 Batu Pahat/Malaysia 的网站上显示时间我正在使用以下代码:

<?php echo date('H:i'); ?>  

but it doesn't show the right time.
my country timezone : Kuala Lumpur/Malaysia my city time now is : 02:24 but on the site it shows me : 08:25
I don't know what time zone my server is in & I can't change that, please help me.

但它没有显示正确的时间。
我的国家时区:吉隆坡/马来西亚我现在的城市时间是:02:24 但在网站上它显示我:08:25
我不知道我的服务器所在的时区,我无法更改,请帮忙我。

回答by

<?php                        
    date_default_timezone_set("Asia/Kuala_Lumpur");
    echo date('d-m-Y H:i:s'); //Returns IST
?>

回答by CustomNet

<?php 
    date_default_timezone_set("Asia/Kolkata"); 
    echo date('d-m-Y H:i:s');
?>

That should do the job, if you don't want it to show day-month-year remove the "d-m-y"

这应该可以完成工作,如果您不希望它显示日-月-年,请删除“dmy”

回答by Ruddy

I think its something like:

我认为它类似于:

date_default_timezone_set('Asia/Kolkata'); //Timezone

Try it out.

试试看。

回答by Realit?tsverlust

date_default_timezone_set('timezone');

Dunno which one you need, look up for it here: http://www.php.net/manual/en/timezones.php

不知道您需要哪一个,请在此处查找:http: //www.php.net/manual/en/timezones.php