DateTime Class

DateTime Class — Represents both a date and time.

Parent Class

Child class of Date.

Members

int day

Day; 1-31.

int hour

Hour; 0-23.

int min

Minute; 0-59.

int month

Month; 1-12.

int sec

Second; 0-59.

int year

Year; 4 digits.

Methods

compare(Date d) : int

Compare two dates. Returns a negative number if d is before the subject in time, positive if it is after, or zero if the two dates are equal. When comparing a Date with a DateTime, the time on the bare Date value is assumed to be midnight.

compare(DateTime d) : int

Compare two dates. Returns a negative number if d is before the subject in time, positive if it is after, or zero if the two dates are equal. When comparing a Date with a DateTime, the time on the bare Date value is assumed to be midnight.

date_format() : string

Returns date formatted as normal. (See also: Section 1.4, “Date Formats”)

date_format(string fmt) : string

Returns date formatted as indicated by $fmt. One of: short, med, long, med_day, long_day. Or a custom format. Default is 'short'. (See also: Section 1.4, “Date Formats”)

day_of_week() : int

Returns the day of the week this date falls on, from Sunday=1 to Saturday=7

time_format() : string

Returns time formatted as normal. (See also: Section 1.4, “Date Formats”)

time_format(string fmt) : string

Returns time formatted as indicated by $fmt, or normal if blank. (See also: Section 1.4, “Date Formats”)