在 PHP 中获取 UTC 时间 [英] get UTC time in PHP
本文介绍了在 PHP 中获取 UTC 时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用 PHP 的 date() 函数获取 UTC/GMT +/- 时间戳?例如,如果我尝试
How can I get UTC/GMT +/- time stamp using PHP's date() function? For example, if I try
date("Y-m-d H:i:s", time());
我会得到Unix时间戳;但我需要根据本地时间获取带有字符串 GMT/UTC+/-0400 或 GMT/UTC+/-1000 的 UTC/GMT 时间戳.
I will get Unix time stamp; but I need to get UTC/GMT time stamp with string GMT/UTC+/-0400 or GMT/UTC+/-1000 based on local timings.
推荐答案
Using gmdate
将始终返回 GMT 日期.语法与 date
相同.
这篇关于在 PHP 中获取 UTC 时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文