如何用PHP显示当地时间 [英] How to display local time with PHP

查看:33
本文介绍了如何用PHP显示当地时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的服务器设置为 GMT 时间,因此春秋两季的时间不会一直跳动.不过在夏令时,很烦,所有的时间都显示一小时.

Our server is set to GMT time so the hour does not keep jumping around in spring and autumn. However, during summer time, it is annoying that all the times are displayed an hour out.

如何获取和显示时间,考虑到 PHP 中的本地时区(尤其是当服务器认为本地时区是 GMT 时).

How do I get and display the time, taking into account the local timezone in PHP (especially when the server thinks the local timezone is GMT).

或者,我如何知道某个地区目前是否在使用夏令时"?

or, How do I know if an area is using "summer time" at the moment?

或者,如何显示 GMT 时间戳或不同的时区?

or, How do I display a GMT time stamp or a different timezone?

推荐答案

其实,我想我可能已经找到了我需要的答案...

Actually, I think I may have found the answer I need...

date_default_timezone_set()
// Sets the default timezone used by all date/time functions in a script 

PHP 手册入口在这里:- http://us2.php.net/manual/en/function.date-default-timezone-set.php

The PHP manual entry is here:- http://us2.php.net/manual/en/function.date-default-timezone-set.php

这篇关于如何用PHP显示当地时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆