PHP strftime() function
Example
Format local date and time according to the locale settings:
<?php
echo(strftime("%B %d %Y, %X %Z",mktime(20,0,0,12,31,98))."<br>");
setlocale(LC_ALL,"hu_HU.UTF8");
echo(strftime("%Y. %B %d. %A. %X %Z"));
?>
Run Example
Definition and Usage
The strftime() function formats local date and time according to the locale settings.
Tip:See also gmstrftime() Function, formats GMT/UTC time/date according to the locale settings.
Syntax
strftime(format,timestamp);
Parameter |
Description |
format |
Required. Specifies how to return the result:
- Abbreviated name of the day of the week
- Full name of the day of the week
- Abbreviated name of the month
- Full name of the month
- Preferred date and time notation
- Number representing the century (year divided by 100, ranging from 00 to 99)
- Day of the month (01 to 31)
- Date format, the same as %m/%d/%y notation
- Day of the month (1 to 31)
- Similar to %G notation, but without the century
- 4-digit year corresponding to the ISO week number (see %V)
- Same as %b notation
- Hour, using 24-hour clock (00 to 23)
- Hour, using 12-hour clock (01 to 12)
- Day of the year (001 to 366)
- Month (01 to 12)
- Minute
- Newline
- am or pm corresponding to the given time value
- a.m. and p.m. time notation
- 24-hour time notation
- Second
- Tab
- Current time, the same as %H:%M:%S notation
- 蒧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, 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), with week 1 representing 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 of the year 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 - Timezone name or abbreviation
- %% - Output a % character
|
timestamp |
Optional. Specifies the Unix timestamp representing the date/time to be formatted. The default is the current time (time()) |
Technical Details
Return Value: |
returns based on format using the given timestamp formatted strings.
The names of months and weekdays and other strings related to languages should comply with setlocale() current locale settings.
|
PHP Version: |
4+ |
Update Log: |
PHP 5.1.0: Added E_STRICT and E_NOTICE timezone errors. |