当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > gmdate() 函数
The gmdate() function formats a GMT/UTC date/time.
gmdate()函数的作用是:格式化一个GMT/UTC日期/时间。
gmdate(format,timestamp) |
Parameter参数 | Description描述 |
---|---|
format | Required. Specifies how to return the result: 必要参数。指定返回结果的方式:
|
timestamp | Optional. 可选参数。指定时间戳 |
<?php echo("Result with date():<br />"); echo(date("l") . "<br />"); echo(date("l dS of F Y h:i:s A") . "<br />"); echo("Oct 3,1975 was on a ".date("l", mktime(0,0,0,10,3,1975))."<br />"); echo(date(DATE_RFC822) . "<br />"); echo(date(DATE_ATOM,mktime(0,0,0,10,3,1975)) . "<br /><br />"); echo("Result with gmdate():<br />"); echo(gmdate("l") . "<br />"); echo(gmdate("l dS of F Y h:i:s A") . "<br />"); echo("Oct 3,1975 was on a ".gmdate("l", mktime(0,0,0,10,3,1975))."<br />"); echo(gmdate(DATE_RFC822) . "<br />"); echo(gmdate(DATE_ATOM,mktime(0,0,0,10,3,1975)) . "<br />"); ?> |
The output of the code above could be something like this:
上述代码将输出下面的结果:
Result with date(): Tuesday Tuesday 24th of January 2006 02:41:22 PM Oct 3,1975 was on a Friday Tue, 24 Jan 2006 14:41:22 CET 1975-10-03T00:00:00+0100 Result with gmdate(): Tuesday Tuesday 24th of January 2006 01:41:22 PM Oct 3,1975 was on a Thursday Tue, 24 Jan 2006 13:41:22 GMT 1975-10-02T23:00:00+0000 |