FUNCTION NAME |
FUNCTION DESCRIPTION |
FUNCTION SYNTAX |
FUNCTION RETURN VALUE |
DateTime::setTimestamp()
date_timestamp_set()
[Sets the date and time based on an Unix timestamp] |
Sets the date and time based on a Unix timestamp. |
Object-oriented style:
DateTime::setTimestamp(unix_timestamp);
Procedural style:
date_timestamp_set(datetime_object, unix_timestamp); |
DateTime::setTimestamp() : returns the DateTime object for method chaining on success; FALSE on failure. |
DateTime::getTimezone()
date_timezone_get()
[Return time zone relative to given DateTime] |
Returns the time zone relative to the given DateTime. |
Object-oriented style:
DateTime::getTimezone();
Procedural style:
date_timezone_get(DateTimeInterface_object); |
Returns a DateTimeInterface object on success; FALSE on failure. |
DateTime::setTimezone()
date_timezone_set()
[Sets the time zone for the DateTime object] |
Sets the time zone for the DateTime object. |
Object-oriented style:
DateTime::setTimezone(timezone);
Procedural style:
date_timezone_set(DateTime_object, timezone); |
DateTime::setTimezone() : returns the DateTime object for method chaining on success; FALSE on failure. |
date()
[Format a local time/date] |
Returns a date string formatted according to the given format string, using the provided timestamp or the current time if no timestamp is given. The optional timestamp defaults to the value of time() . |
date(format, timestamp [optional parameter]);
[formatting options: d [day: 01 — 31]; D [3-letter day representation: Mon — Sun]; j [day: 1 — 31]; l [day: Monday — Sunday]; N [ISO-8601 day representation: 1 (Monday) — 7 (Sunday)]; S [st, nd, rd, th]; w [0 (Sunday) — 6 (Saturday)]; z [Day of year: 0 — 365]; W [ISO-8601 week number of year, starting on Monday]; F [full month name: January — December]; m [numerical month representation: 01 — 12]; M [month name: jan — dec]; n [numerical month representation: 1 -12]; t [number of days in given month: 28 – 31]; L [uppercase ‘l’ — leap year?1:0]; o [ISO-8601 week-numbering year; same value as Y except that if W belongs to the previous or next year, that year is used instead — 1999, 2003]; Y [4-digit year representation — 1999, 2003]; y [2-digit year representation — 99, 03]; a [lowercase Ante meridiem and Post meridiem]; A [uppercase Ante meridiem and Post meridiem]; B [Swatch Internet time — 000 – 999]; g [12-hour time format: 1 — 12]; G [24-hour time format: 0 — 23]; h [12-hour time format: 01 – 12]; H [24-hour time format: 00 – 23]; i [minutes — 00 – 59]; s [seconds – 00 – 59]; u [microseconds: date() will always generate 000000, whereas DateTime::format() does support microseconds if DateTime is instantiated with microseconds — 654321]; v [milliseconds: same rules apply as for u — 654]; e [timezone identifier: UTC, GMT, Atlantic/Azores]; I [uppercase ‘i’ — Daylight Savings Time?1:0]; O [difference to GMT in hours — +0200]; P [difference to GMT in ‘hours:mins’ format — +02:00]; T [timezone abbreviation: EST, MDT]; Z [timezone offset from UTC in seconds; timezones west of UTC are always negative, timezones east of UTC are always positive: -43200 — 50400]; c [ISO-8601 date: 2004-02-12T15:19:21+00:00]; r [RFC 2822-formatted date: Thu, 21 Dec 2000 16:01:07 +0200]; and U [seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)].
Unrecognised characters will be printed as-is. ] |
Returns a formatted date string. If a non-numeric value is used for timestamp, FALSE is returned and an E_WARNING level error is emitted. |
getdate()
[Get date/time information] |
Returns an associative array containing the date information of timestamp or the current local time if timestamp is not provided. |
getdate(timestamp [optional parameter defaulting to value of time() ]); |
Returns an associative array containing date information relating to timestamp. Elements comprise: ‘seconds’ [0-59]; ‘minutes’ [0-59]; ‘hours’ [0-23]; ‘mday’ [1-31]; ‘wday’ [0 (Sunday) – 6 (Saturday)]; ‘mon’ [1-12]; ‘year’ [1999, 2003]; ‘yday’ [0-365]; ‘weekday’ [Sunday — Saturday]; ‘month’ [January — December]; ‘0’ [seconds since the Unix Epoch: system-dependent, typically from -2147483648 — 2147483647]. |
gettimeofday()
[Get current time] |
An interface call to gettimeofday(2) ; it returns the time of day information-related associative array returned from the system call. |
gettimeofday(return_float [optional boolean parameter – if ‘true’ then a float is returned instead of an associative array]); |
If return_float is true then a float is returned. Otherwise, an associative array is returned, comprising the following time of day elements: ‘secs’ [seconds since the Unix Epoch]; ‘usec’ [microseconds]; ‘minuteswest’ [minutes west of Greenwich]; and ‘dsttime’ [type of dst correction]. |
gmdate()
[Format a GMT/UTC date/time] |
Identical to the date() function, except that the time returned is GMT. |
gmdate(format, timestamp [optional parameter, defaulting to value of time() ]);
[The valid range of timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT.] |
gmdate() : returns a formatted date string. If a non-numeric value is used for timestamp, FALSE is returned and an E_WARNING level error is emitted. |
gmmktime()
[Get Unix timestamp for a GMT date] |
Identical to mktime() except that the passed parameters represents a GMT date. Returns the Unix timestamp for the created date. |
gmmktime(hour, minute, second, month, day, year, is_dst);
[All parameters above are optional. Defaults: hour — gmdate("H") ; minute — gmdate("i") ; second — gmdate("s") ; month — gmdate("n") ; day — gmdate("j") ; year — gmdate("Y") ; is_dst = -1.] |
gmmktime() : returns an integer Unix timestamp. |
gmstrftime()
[Format a UTC/GMT time/date according to locale settings] |
Behaves the same as strftime() except that the formatted time string returned is GMT. |
gmstrftime(format, timestamp [optional parameter, defaulting to the value of time() ]); |
gmstrftime() : returns a string formatted according to the given format using timestamp if given, or the value of time() . Month and weekday names and other language-dependent strings respect the current locale set with setlocale() . |
idate()
[Format a local time/date as integer] |
Returns a number formatted according to format using the timestamp parameter if present, or the current local time() if not. idate() accepts just one char in the format parameter. |
idate(format, timestamp [optional parameter]);
[The following characters can be used as the format string: B; d; h; H; i; I; l; m; s; t; U; w; W; y; Y; z; and Z. Please cross-reference the format codes used in the date() function, detailed above.] |
Always returns an integer. Since integers cannot start with 0, this function may return fewer digits than initially expected. Every call to a date/time function will generate an E_NOTICE if the timezone is not valid, and/or a E_STRICT or E_WARNING message if using the system settings or the TZ environment variable. |
localtime()
[Get the local time] |
Returns an array of local time-related elements. If is_associative is set to true, the associative array contains all the different elements of the structure returned by the C function call to localtime . The different keys of the associative array are: ‘tm_sec’ (0 — 59); ‘tm_min’ (0 — 59); ‘tm_hour’ (0 — 23); ‘tm_mday’ (1 — 31); ‘tm_mon’ (0 [Jan] — 11 [Dec]); ‘tm_year’ (years since 1900); ‘tm_wday’ (0 [Sun] — 6 [Sat]); ‘tm_yday’ (0 — 365); ‘isdst’ (?1:0:-) [DST? positive if yes:0 if no:negative if unknown]. |
localtime(timestamp [optional parameter, defaulting to value of time() ], is_associative [optional parameter, with a default value of false]); . |
If is_associative is set to false or not provided, a numerically-indexed array is returned. If is_associative is set to true, an associative array is returned. |