Definition and Usage
The strftime() function formats a local time or date according to locale settings.Syntax
strftime(format,timestamp)
| Parameter | Description |
|---|---|
| format |
Required. Specifies how to return the result:
|
| timestamp | Optional. Specifies the date or time to be formatted. If no timestamp is specified, it uses the current local time. |
Tips and Notes
Tip: This function is identical to gmstrftime() except that the time returned is local time.Example
Example of both strftime() and gmstrftime():
<?php
echo(strftime("%b %d %Y %X", mktime(20,0,0,12,31,98))."<br />");
echo(gmstrftime("%b %d %Y %X", mktime(20,0,0,12,31,98))."<br />");
//Print the current date, time, and time zone.
echo(gmstrftime("It is %a on %b %d, %Y, %X time zone: %Z",time()));
?>
echo(strftime("%b %d %Y %X", mktime(20,0,0,12,31,98))."<br />");
echo(gmstrftime("%b %d %Y %X", mktime(20,0,0,12,31,98))."<br />");
//Print the current date, time, and time zone.
echo(gmstrftime("It is %a on %b %d, %Y, %X time zone: %Z",time()));
?>
OUTPUT :
Dec 31 1998 20:00:00
Dec 31 1998 19:00:00
It is Wed on Jan 25, 2006, 11:32:10 time zone: W. Europe Standard Time
Dec 31 1998 19:00:00
It is Wed on Jan 25, 2006, 11:32:10 time zone: W. Europe Standard Time