Home >>PHP Date Time Functions >PHP strftime() Function
PHP strftime() function formats a given local time or date according to the specified locale settings. It accepts two parameters $timestamp and $format. If timestamp is not given then it returns the current local time. It returns a string as output formatted according to the given format string using the given timestamp or the current local time.
Syntax:
strftime(format, timestamp);
Parameter | Description |
---|---|
format | This is a required parameter. This parameter defines how to return the result. |
timestamp | This is an optional parameter. This parameter defines a Unix timestamp that represents the date and time to be formatted. |
Here is an example of strftime() function in PHP:
<html> <body> <?php echo strftime("%d %B %Y, %X",mktime(20,23,45,6,10,2020) )."<br>"; ?> </body> </html>
Example 2:
<html> <body> <?php echo strftime("%d %B %Y, %X (%A)",mktime(20,23,45,6,10,2020))."<br>"; setlocale(LC_ALL,"hu_HU.UTF8"); echo strftime("%d %B %Y, %X (%A)"); ?> </body> </html>