date() displays a date in the format specified in the format argument. Dates and times can be displayed in any order and combination, with any delimiters. An optional second argument can be used to format the date from a specific time. If the second argument is omitted, the current time is used.
This function uses single characters as format specifiers; if you want to put other text directly into the format string, use strftime() instead. Otherwise, you could get unexpected results as characters from the text are converted into date values (see the example).
The following list describes the format arguments:
The O specifier was added in version 4.0.2. The r specifier was added in version 4.0.4.
/* When tested at 12:47 on April 20 2001, * the following code produced this output: * * At the tone, the time will be: Friday April 20th 2001, 12:47 * PM30 3012e 30o4e, 3012e 304704e 547FridayFriday be: Friday April 20th 2001, 12:47 */ /* Produces the desired output: */ print("At the tone, the time will be: " . date("l F dS Y, H:i")); /* This probably doesn't produce what you want. */ print(date("At the tone, the time will be: l F dS Y, H:i"));
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.