PHP strftime() Function
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"));
?>
Try it Yourself »
Definition and Usage
The strftime() function formats a local time and/or date according to locale settings.
Note: This function was deprecated in PHP 8.1.0.
Syntax
strftime(format, timestamp)
Parameter Values
| Parameter | Description |
|---|---|
| format | Required. Specifies how to return the result:
|
| timestamp | Optional. Specifies a Unix timestamp that represents the date and/or time to be formatted. Default is the current local time (time()) |
Technical Details
| Return Value: | Returns a string formatted according format using the given timestamp. Month and weekday names and other language-dependent strings respect the current locale set with setlocale() |
|---|---|
| PHP Version: | 4+ |
| PHP Changelog: | PHP 5.1: Now issues E_STRICT and E_NOTICE time zone errors |
❮ PHP Date/Time Reference