Format local date and time according to 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 " ) ) ; ?>The strftime() function formats local dates and times according to locale settings.
Tip: Check out the gmstrftime() function to format GMT/UTC times/dates according to your locale.
strftime( format,timestamp);
parameter | describe |
---|---|
format | Required. Specify how to return results: %a - abbreviation for day of the week name %A - the full name of the day of the week %b - abbreviation for month name %B - Full month name %c - Preferred date and time representation %C - century number (year divided by 100, range 00 to 99) %d - day of the month (01 to 31) %D - time format, 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 ISO week number (see %V) %h - same notation as %b %H - hour, using 24-hour clock (00 to 23) %I - hour, using 12-hour clock (01 to 12) %j - Day of the year (001 to 366) %m - month (01 to 12) %M - points %n - newline character %p - am or pm corresponding to the given time value %r - time notation for am and pm %R - 24-hour time notation %S - seconds %t - tab tab character %T - current time, same notation as %H:%M:%S %u - Numeric representation of the day of the week (1 to 7), Monday = 1. Warning: Sunday = 1 on Sun Solaris systems %U - the number of weeks included in the current year, starting with the first Sunday as the first day of week 1 %V - The number of weeks (01 to 53) in ISO 8601 format contained in the current year. Week 1 represents the first week of the year, which must have at least four days, and Monday is the first day of the week. %W - the number of weeks included in the year, starting with the first Monday as the first day of week 1 %w - Day of the week as a decimal number, Sunday = 0 %x - Preferred date representation without time %X - Preferred time representation without date %y - year representation without century digits (range 00 to 99) %Y - Year representation including a digit representing the century %Z or %z - time zone name or abbreviation %% - output a % character |
timestamp | Optional. Unix timestamp specifying the date/time to be formatted. Defaults to the current time (time()). |
Return value: | Returns a string formatted according to format using the given timestamp . Month and day of the week names and other language-related strings respect the current locale in setlocale(). |
---|---|
PHP version: | 4+ |
Update log: | PHP 5.1.0: Added E_STRICT and E_NOTICE time zone errors. |