PhpDig.net

What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.




date

Name

date — Formats a UNIX timestamp into a human-readable string.

Synopsis

string date(format[, time]);
string format: Format in which to display the calculated date
int time (optional): Time in UNIX time format

Returns

Formatted date output

Description

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:

  • a: am or pm

  • A: AM or PM

  • B: Swatch[tm] beat (also known as "Internet time"; this is a new time standard introduced by Swiss watchmaker Swatch)

  • d: Numeric day of the month

  • D: Short day abbreviation

  • F: Full month name

  • g: 12-hour time without leading zero

  • G: 24-hour time without leading zero

  • h: 12-hour time with leading zero

  • H: 24-hour time with leading zero

  • i: minutes with leading zero

  • I: (capital "i') 1 if Daylight Saving Time, 0 otherwise

  • j: day of month without leading zero

  • l: (lowercase "L") Full day name

  • L: Boolean indicating a leap year (set to 1 if leap year)

  • m: Numeric month with leading zero

  • M: Short month abbreviation

  • n: Numeric month without leading zero

  • O: GMT offset in [+-]HHMM format

  • r: RFC 822 format

  • s: seconds

  • S: suffix to numerical date (for example, 1st or 4th)

  • t: Number of days in this month (28 - 31)

  • T: Time zone name

  • U: UNIX seconds

  • w: Numeric day of the week

  • y: Two-digit year

  • Y: Four-digit year

  • z: Day number in the year

  • Z: Offset of current time zone to GMT in minutes (-43200 to 43200)



Note

The O specifier was added in version 4.0.2. The r specifier was added in version 4.0.4.

Version

PHP 3, PHP 4

Example

Example 198. Print a formatted date

/* 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.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.