PHP 8.3.4 Released!

gmdate

(PHP 4, PHP 5, PHP 7, PHP 8)

gmdate格式化 GMT/UTC 日期/时间

说明

gmdate(string $format, ?int $timestamp = null): string

date() 函数一样,只是返回的时间是格林威治标准时(GMT)。

参数

format

输出日期 string 的格式。参阅 date() 函数格式化选项。

timestamp

可选的 timestamp 参数是一个 int 的 Unix 时间戳,如未指定或是 null,参数值默认为当前本地时间。也就是说,其值默认为 time() 的返回值。

返回值

返回格式化的日期字符串。

更新日志

版本 说明
8.0.0 现在 timestamp 允许为 null。

示例

示例 #1 gmdate() 示例

在芬兰(GMT +0200)运行时,下面的第一行打印“Jan 01 1998 00:00:00”,第二行打印“Dec 31 1997 22:00:00”。

<?php
echo date("M d Y H:i:s", mktime(0, 0, 0, 1, 1, 1998));
echo
gmdate("M d Y H:i:s", mktime(0, 0, 0, 1, 1, 1998));
?>

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top