gpt4 book ai didi

php - PHP 的 gmtime() 在哪里?

转载 作者:可可西里 更新时间:2023-11-01 00:58:36 24 4
gpt4 key购买 nike

有两个标准的 C 库函数 gmtime() and localtime() .他们都返回这样的结构(一个在 GMT,一个在本地 TZ 和夏令时):

struct tm {
int tm_sec; /* seconds */
int tm_min; /* minutes */
int tm_hour; /* hours */
int tm_mday; /* day of the month */
int tm_mon; /* month */
int tm_year; /* year */
int tm_wday; /* day of the week */
int tm_yday; /* day in the year */
int tm_isdst; /* daylight saving time */
};

PHP 对 localtime() 进行了包装,但据我所知不是 gmtime()。我错过了什么? PHP 的 gmtime() 包装器在哪里?

我确实找到了一个非常古老的 PHP gmtime() 请求 - https://bugs.php.net/bug.php?id=576&edit=1 .但它已关闭并因不需要而被驳回。我不同意。

不需要它。但是将 struct tm 从本地时间转换为 GMT 并非微不足道(AFAIK),因此拥有它会很好。和拥有 localtime() 一样好。

最佳答案

正如函数 time() 的文档 ( http://php.net/manual/en/function.time.php) 所述:

“返回以 Unix 纪元(1970 年 1 月 1 日 00:00:00 GMT)以来的秒数为单位的当前时间。”

所以 gmtime 就是 time()。

关于php - PHP 的 gmtime() 在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34083787/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com