Easy Tutorial
❮ Php Getimagesizefromstring Func Math Abs ❯

PHP strftime() Function

PHP Date/Time Reference Manual

Example

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"));
?>

Definition and Usage

The strftime() function formats the local date and time according to locale settings.

Tip: See the gmstrftime() function to format the GMT/UTC date and time according to locale settings.

Syntax

Parameter Description
format Required. Specifies how to return the result: %a - Abbreviated weekday name<br> %A - Full weekday name<br> %b - Abbreviated month name<br> %B - Full month name<br> %c - Preferred date and time representation<br> %C - Century number (the year divided by 100, range 00 to 99)<br> %d - Day of the month (01 to 31)<br> %D - Same as %m/%d/%y<br> %e - Day of the month (1 to 31)<br> %g - Like %G, but without the century<br> %G - 4-digit year corresponding to the ISO week number (see %V)<br> %h - Same as %b<br> %H - Hour, using a 24-hour format (00 to 23)<br> %I - Hour, using a 12-hour format (01 to 12)<br> %j - Day of the year (001 to 366)<br> %m - Month (01 to 12)<br> %M - Minute<br> %n - Newline character<br> %p - Either am or pm according to the given time value<br> %r - Time in a.m. and p.m. notation<br> %R - Time in 24 hour notation<br> %S - Second<br> %t - Tab character<br> %T - Current time, equal to %H:%M:%S<br> %u - Day of the week as a number (1 to 7), Monday = 1. Warning: In Sun Solaris Sunday = 1<br> %U - Week number of the current year, starting with the first Sunday as the first day of the first week<br> %V - ISO 8601 week number of the current year (01 to 53), where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week<br> %W - Week number of the current year, starting with the first Monday as the first day of the first week<br> %w - Day of the week as a decimal, Sunday = 0<br> %x - Preferred date representation without the time<br> %X - Preferred time representation without the date<br> %y - Year without a century (range 00 to 99)<br> %Y - Year including the century<br> %Z or %z - Time zone or name or abbreviation<br> %% - A literal % character
timestamp Optional. Specifies the Unix timestamp to be formatted. Default is the current local time (time()).

Technical Details

Return Value: Returns a string formatted according to the given format string using the given timestamp or the current local time if no timestamp is given. Names of the months and the days of the week and other language-dependent strings respect the current locale set with setlocale().
PHP Version: 4+
--- ---
Changelog: PHP 5.1.0: Added E_STRICT and E_NOTICE timezone errors. <br>
--- ---
❮ Php Getimagesizefromstring Func Math Abs ❯