class JDate extends DateTime


Located at : UKNOWVA_ROOT/libraries/joomla/utilities/date.php

JDate is a class that stores a date and provides logic to manipulate and render that date in a variety of formats.

Constants

DAY_ABBR

DAY_NAME

MONTH_ABBR

MONTH_NAME

Properties

static string $format The format string to be applied when using the __toString() magic method.

Methods

void
__construct(string $date = 'now', mixed $tz = null)

Constructor.

mixed
__get(string $name)

Magic method to access properties of the date given by class to the format method.

string
__toString()

Magic method to render the date object in the format specified in the public static member JDate::$format.

string
calendar(string $format, boolean $local = false, boolean $translate = true)

Gets the date as a formatted string in a local calendar.

string
format(string $format, boolean $local = false, boolean $translate = true)

Gets the date as a formatted string.

float
getOffsetFromGMT(boolean $hours = false)

Get the time offset from GMT in hours or seconds.

boolean
setOffset(float $offset) deprecated

Set the date offset (in hours).

setTimezone(object $tz)

Method to wrap the setTimezone() function and set the internal time zone object.

string
toFormat(string $format = '%Y-%m-%d %H:%M:%S', boolean $local = false) deprecated

Gets the date in a specific format

string
toISO8601(boolean $local = false)

Gets the date as an ISO 8601 string. IETF RFC 3339 defines the ISO 8601 format and it can be found at the IETF Web site.

string
toMySQL(boolean $local = false)

Gets the date as an MySQL datetime string.

string
toRFC822(boolean $local = false)

Gets the date as an RFC 822 string. IETF RFC 2822 supercedes RFC 822 and its definition can be found at the IETF Web site.

integer
toUnix()

Gets the date as UNIX time stamp.

Details

at line 123
void __construct(string $date = 'now', mixed $tz = null)

Constructor.

Parameters

string $date String in a format accepted by strtotime(), defaults to "now".
mixed $tz Time zone to be used for the date.

Return Value

void

Exceptions

JException

at line 167
mixed __get(string $name)

Magic method to access properties of the date given by class to the format method.

Parameters

string $name The name of the property.

Return Value

mixed A value if the property name is valid, null otherwise.

at line 245
string __toString()

Magic method to render the date object in the format specified in the public static member JDate::$format.

Return Value

string The date as a formatted string.

at line 284
string calendar(string $format, boolean $local = false, boolean $translate = true)

Gets the date as a formatted string in a local calendar.

Parameters

string $format The date format specification string (see {@link PHP_MANUAL#date})
boolean $local True to return the date string in the local time zone, false to return it in GMT.
boolean $translate True to translate localised strings

Return Value

string The date string in the specified format format.

at line 300
string format(string $format, boolean $local = false, boolean $translate = true)

Gets the date as a formatted string.

Parameters

string $format The date format specification string (see {@link PHP_MANUAL#date})
boolean $local True to return the date string in the local time zone, false to return it in GMT.
boolean $translate True to translate localised strings

Return Value

string The date string in the specified format format.

at line 352
float getOffsetFromGMT(boolean $hours = false)

Get the time offset from GMT in hours or seconds.

Parameters

boolean $hours True to return the value in hours.

Return Value

float The time offset from GMT either in hours or in seconds.

at line 395
boolean setOffset(float $offset) deprecated

deprecated 12.1

Set the date offset (in hours).

Parameters

float $offset The offset in hours.

Return Value

boolean True on success.

at line 417
DateTimeZone setTimezone(object $tz)

Method to wrap the setTimezone() function and set the internal time zone object.

Parameters

object $tz The new DateTimeZone object.

Return Value

DateTimeZone The old DateTimeZone object.

at line 436
string toFormat(string $format = '%Y-%m-%d %H:%M:%S', boolean $local = false) deprecated

deprecated Use JDate::format() instead.

Gets the date in a specific format

Returns a string formatted according to the given format. Month and weekday names and other language dependent strings respect the current locale

Parameters

string $format The date format specification string (see {@link PHP_MANUAL#strftime})
boolean $local True to return the date string in the local time zone, false to return it in GMT.

Return Value

string The date as a formatted string.

at line 483
string toISO8601(boolean $local = false)

Gets the date as an ISO 8601 string. IETF RFC 3339 defines the ISO 8601 format and it can be found at the IETF Web site.

Parameters

boolean $local True to return the date string in the local time zone, false to return it in GMT.

Return Value

string The date string in ISO 8601 format.

at line 499
string toMySQL(boolean $local = false)

Gets the date as an MySQL datetime string.

Parameters

boolean $local True to return the date string in the local time zone, false to return it in GMT.

Return Value

string The date string in MySQL datetime format.

at line 516
string toRFC822(boolean $local = false)

Gets the date as an RFC 822 string. IETF RFC 2822 supercedes RFC 822 and its definition can be found at the IETF Web site.

Parameters

boolean $local True to return the date string in the local time zone, false to return it in GMT.

Return Value

string The date string in RFC 822 format.

at line 527
integer toUnix()

Gets the date as UNIX time stamp.

Return Value

integer The date as a UNIX timestamp.