PHP gmstrftime() function
Examples
Format GMT/UTC date and time according to the locale:
<?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"));
?>
Try it Yourself
Definition and Usage
gmstrftime() function formats GMT/UTC date and time according to the locale.
Tip:See also strftime() Function, formats local time/date according to the locale.
Syntax
gmstrftime(format,timestamp);
Parameter |
Description |
format |
Required. Defines how the result is returned: %a - abbreviated weekday name
- %A - full weekday name
- %b - abbreviated month name
- %B - full month name
- %c - preferred date and time representation
- %C - century as a number (year divided by 100, range from 00 to 99)
- %d - day of the month (01 to 31)
- %D - date format, the same as %m/%d/%y notation
- %e - day of the month (1 to 31)
- %g - similar to %G notation, but without the century
- %G - 4-digit year corresponding to the ISO week number (see %V)
- %h - same as %b notation
- %H - hour using 24-hour format (00 to 23)
- %I - hour using 12-hour format (01 to 12)
- %j - day of the year (001 to 366)
- %m - month (01 to 12)
- %M - minutes
- %n - newline character
- %p - am or pm corresponding to the given time value
- %r - a.m. and p.m. time notation
- %R - 24-hour time notation
- %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, as the first week, with the first day as the first day of the 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 Monday, as the first week, with the first day as the first day of the week
- %w - Decimal representation of the day of the week, Sunday[星期日] = 0
- %x - Preferred date representation without time
- %X - Preferred time representation without date
- %y - Year representation that does not include a number representing the century (range from 00 to 99)
- %Y - Year representation that includes a number representing the century
- %Z or %z - Time zone name or abbreviation
- %% - Output a % character
|
timestamp |
Optional. Specifies the Unix timestamp representing 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.
the names of months and days of the week, and other language-related strings comply with setlocale() current locale settings.
|
PHP Version: |
4+ |