 |
|
PhpDig.net
|
What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.
|
strftime
Name
strftime — Formats a local time or date according to
locale settings.
Synopsis
string strftime (format[, timestamp]);
string format: Format for
time and date
int timestamp (optional):
Date information to be formatted
Returns
Formatted date string; FALSE on error
Description
strftime() provides a date-formatting
functionality that resembles a combination of the sprintf() and date() functions. However, it
also takes into account the locale settings of the system
on which it executes, so locale- and language-dependent
items in the string will be formatted and printed
correctly.
If timestamp is not given, the
current time will be used.
Quite a large number of format specifiers are available
for strftime() , but not all of them are supported
by all systems. (PHP uses the underlying system calls to
provide this service.) Where applicable, the following
are all locale-specific. For instance, in the "C" locale,
%B might produce January, while in the
"fi_FI" locale, it might produce tammikuu. The
format specifiers are as follows (unless otherwise noted,
all integers are left-zero-padded):
-
%a: Weekday name, abbreviated
-
%A: Weekday name
-
%b: Month name, abbreviated
-
%B: Month name
-
%c: Preferred date-and-time representation
for the current locale
-
%C: Century number, expressed as a
two-digit integer in the range
00-99
-
%d: Day of the month, expressed as a
two-digit integer in the range
01-31
-
%D: Same as %m/%d/%y
-
%e: Day of the month, expressed as an
unpadded one-digit or two-digit integer in the
range1-31
-
%h: Same as %b
-
%H: Hour, expressed as a two-digit integer
in 24-hour clock format in the
range00-24
-
%I: Hour, expressed as a two-digit integer
in 12-hour clock format in the
range00-12
-
%j: Day of the year, expressed as a
three-digit integer in the range
001-366
-
%m: Month, expressed as an integer in the
range01-12
-
%M: Minute, expressed as an integer in the
range00-59
-
%n: Newline character (ASCII0x10)
-
%p: The string'AM'or'PM'
as appropriate for the given time (may be
translated for the current locale)
-
%r: Time in 12-hour clock format with
seconds; same as %I:%M:%S %p
-
%R: Time in 24-hour clock format without
seconds; same as %H:%M
-
%S: Seconds, expressed as a two-digit
decimal number in the range 00-59
-
%t: Tab character (ASCII0x9)
-
%T: Time in 24-hour clock format with
seconds; same as %H:%M:S
-
%u: Weekday expressed as a single-digit
integer in the range 1-7, where
Monday is day1
-
%U: Week number, expressed as an integer
in the range 00-53, where the
first Sunday is the first day of the first week
-
%V: Week number, expressed as an integer
in the range 00-53, where
week01 is the first week with four or more
of its days within the year, and Monday as the
first day of the week (ISO 8601:1998 format)
-
%W: Week number, expressed as an integer
in the range 00-53, where the
first Monday is the first day of the first week
-
%x: Date expressed in the preferred
representation for the current locale, not
including the time
-
%X: Time expressed in the preferred
representation for the current locale, not
including the date
-
%y: Year, expressed as a two-digit integer
in the range 00-99
-
%Y: Year, expressed as a two-digit integer
in the range 1970-2037
-
%Z: Current time zone or its name or
abbreviation
-
%%: Literal percent sign
Example
Example 207. Use
strftime()
/* When tested at 23:30 on April 19, 2001 in
* western Canada, the following code
* produced this output:
*
* It is now Thursday April 19, 2001, at 23:30:11 (time zone: PDT).
*/
/* Print the current date, time, and time zone. */
echo strftime("It is now %A %B %e, 2001, at %X (time zone: %Z).\n", time());
PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing
(Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch).
This material may be distributed only subject to the terms and conditions set forth
in the Open Publication License, v1.0 or later (the latest version is presently available at
http://www.opencontent.org/openpub/).
The authors of this book have elected not to choose any options under the OPL. This online book was obtained
from http://www.fooassociates.com/phpfer/
and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4
for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All
persons and entities shall have neither liability nor responsibility to any person or entity with respect to
any loss or damage arising from the information contained in this book.
|