PHP gmstrftime() 函数

实例

根据区域设置来格式化 GMT/UTC 日期和时间:

<?php
echo(gmstrftime("%B %d %Y, %X %Z",mktime(20,0,0,12,31,98))."<br>");
setlocale(LC_ALL,"hu_HU.UTF8");
echo(gmstrftime("%Y. %B %d. %A. %X %Z"));
?>

运行实例

定义和用法

gmstrftime() 函数根据区域设置格式化 GMT/UTC 日期和时间。

提示:请参阅 strftime() 函数,根据区域设置格式化本地时间/日期。

语法

gmstrftime(format,timestamp);
参数 描述
format

必需。规定如何返回结果:%a - 星期几名称的简写

  • %A - 星期几名称的全称
  • %b - 月份名称的简写
  • %B - 月份名称的全称
  • %c - 首选的日期和时间表示法
  • %C - 表示世纪的数字(年份除以 100,范围从 00 到 99)
  • %d - 一个月中的第几天(01 到 31)
  • %D - 时间格式,与 %m/%d/%y 表示法相同
  • %e - 一个月中的第几天(1 到 31)
  • %g - 与 %G 表示法类似,但不带世纪
  • %G - 与 ISO 星期数对应的 4 位数年份(见 %V)
  • %h - 与 %b 表示法相同
  • %H - 小时,使用 24 小时制(00 到 23)
  • %I - 小时,使用 12 小时制(01 到 12)
  • %j - 一年中的第几天(001 到 366)
  • %m - 月份(01 到 12)
  • %M - 分
  • %n - 换行符
  • %p - 与给定的时间值相对应的 am 或 pm
  • %r - a.m. 和 p.m. 的时间标记法
  • %R - 24 小时制的时间标记法
  • %S - Seconds
  • %t - Tab
  • %T - Current time, the same as the %H:%M:%S representation
  • 蒧umeric representation of the day of the week (1 to 7), Monday[星期一] = 1. Warning: In Sun Solaris systems, Sunday[星期日] = 1
  • %U - The number of weeks contained in the year, starting from the first Sunday of the year as the first week
  • %V - The number of weeks contained in the year according to the ISO 8601 format (01 to 53), week 1 represents the first week of the year, which must have at least four days and start with Monday as the first day of the week
  • %W - The number of weeks contained in the year, starting from the first Sunday of the year as the first week
  • %w - Decimal number representing the day of the week, Sunday[星期日] = 0
  • %x - Preferred date representation without time
  • %X - Preferred time representation without date
  • %y - Year representation without a number indicating the century (range from 00 to 99)
  • %Y - Year representation containing a number indicating the century
  • %Z or %z - Time zone name or abbreviation
  • %% - Output a % character
timestamp Optional. Specifies the Unix timestamp of the date/time to be formatted. The default is the current local time (time())

Technical Details

Return value:

returns based on format using the given timestamp formatted strings.

Names of months and days of the week and other language-related strings comply with setlocale() current locale settings.

PHP Version: 4+