JDate
Extends \DateTimeJDate is a class that stores a date and provides logic to manipulate and render that date in a variety of formats.
package |
Joomla.Platform |
---|---|
subpackage |
Utilities |
since |
11.1 |
Methods
__construct
Constructor.
__construct(string $date = 'now', mixed $tz = null)
since |
11.1 |
---|---|
throws |
|
Arguments
- $date
string
String in a format accepted by strtotime(), defaults to "now".- $tz
mixed
Time zone to be used for the date.
__get
Magic method to access properties of the date given by class to the format method.
__get(string $name) : mixed
since |
11.1 |
---|
Arguments
- $name
string
The name of the property.
Response
mixed
A value if the property name is valid, null otherwise.
__toString
Magic method to render the date object in the format specified in the public static member JDate::$format.
__toString() : string
since |
11.1 |
---|
Response
string
The date as a formatted string.
calendar
Gets the date as a formatted string in a local calendar.
calendar(string $format, boolean $local = false, boolean $translate = true) : string
since |
11.1 |
---|
Arguments
- $format
string
The date format specification string (see {@link PHP_MANUAL#date})- $local
boolean
True to return the date string in the local time zone, false to return it in GMT.- $translate
boolean
True to translate localised strings
Response
string
The date string in the specified format format.
dayToString
Translates day of week number to a string.
dayToString(integer $day, boolean $abbr = false) : string
since |
11.1 |
---|
Arguments
- $day
integer
The numeric day of the week.- $abbr
boolean
Return the abbreviated day string?
Response
string
The day of the week.
format
Gets the date as a formatted string.
format(string $format, boolean $local = false, boolean $translate = true) : string
since |
11.1 |
---|
Arguments
- $format
string
The date format specification string (see {@link PHP_MANUAL#date})- $local
boolean
True to return the date string in the local time zone, false to return it in GMT.- $translate
boolean
True to translate localised strings
Response
string
The date string in the specified format format.
getInstance
Proxy for new JDate().
getInstance(string $date = 'now', mixed $tz = null) : \JDate
since |
11.3 |
---|---|
throws |
|
Arguments
- $date
string
String in a format accepted by strtotime(), defaults to "now".- $tz
mixed
Time zone to be used for the date.
Response
getOffsetFromGMT
Get the time offset from GMT in hours or seconds.
getOffsetFromGMT(boolean $hours = false) : float
since |
11.1 |
---|
Arguments
- $hours
boolean
True to return the value in hours.
Response
float
The time offset from GMT either in hours or in seconds.
monthToString
Translates month number to a string.
monthToString(integer $month, boolean $abbr = false) : string
since |
11.1 |
---|
Arguments
- $month
integer
The numeric month of the year.- $abbr
boolean
If true, return the abbreviated month string
Response
string
The month of the year.
setOffset
Set the date offset (in hours).
setOffset(float $offset) : boolean
since |
11.1 |
---|---|
deprecated |
12.1 Use setTimezone instead. |
Arguments
- $offset
float
The offset in hours.
Response
boolean
True on success.
setTimezone
Method to wrap the setTimezone() function and set the internal time zone object.
setTimezone(object $tz) : \DateTimeZone
since |
11.1 |
---|
Arguments
- $tz
object
The new DateTimeZone object.
Response
\DateTimeZone
The old DateTimeZone object.
toFormat
Gets the date in a specific format
toFormat(string $format = '%Y-%m-%d %H:%M:%S', boolean $local = false) : string
Returns a string formatted according to the given format. Month and weekday names and other language dependent strings respect the current locale
deprecated |
Use JDate::format() instead. 12.1 Use JDate::format() instead. |
---|
Arguments
- $format
string
The date format specification string (see {@link PHP_MANUAL#strftime})- $local
boolean
True to return the date string in the local time zone, false to return it in GMT.
Response
string
The date as a formatted string.
toISO8601
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.
toISO8601(boolean $local = false) : string
link | |
---|---|
since |
11.1 |
Arguments
- $local
boolean
True to return the date string in the local time zone, false to return it in GMT.
Response
string
The date string in ISO 8601 format.
toMySQL
Gets the date as an MySQL datetime string.
toMySQL(boolean $local = false) : string
link | |
---|---|
since |
11.1 |
deprecated |
12.1 Use JDate::toSql() |
Arguments
- $local
boolean
True to return the date string in the local time zone, false to return it in GMT.
Response
string
The date string in MySQL datetime format.
toRFC822
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.
toRFC822(boolean $local = false) : string
link | |
---|---|
since |
11.1 |
Arguments
- $local
boolean
True to return the date string in the local time zone, false to return it in GMT.
Response
string
The date string in RFC 822 format.
toSql
Gets the date as an SQL datetime string.
toSql(boolean $local = false, \JDatabase $dbo = null) : string
link | |
---|---|
since |
11.4 |
Arguments
- $local
boolean
True to return the date string in the local time zone, false to return it in GMT.- $dbo
\JDatabase
The database driver or null to use JFactory::getDbo()
Response
string
The date string in SQL datetime format.
toUnix
Gets the date as UNIX time stamp.
toUnix() : integer
since |
11.1 |
---|
Response
integer
The date as a UNIX timestamp.
Constants
DAY_ABBR
Value | "\x021\x03" |
---|
Type(s)
DAY_NAME
Value | "\x022\x03" |
---|
Type(s)
MONTH_ABBR
Value | "\x023\x03" |
---|
Type(s)
MONTH_NAME
Value | "\x024\x03" |
---|
Type(s)
Properties
format
The format string to be applied when using the __toString() magic method.
since |
11.1 |
---|
Type(s)
string
gmt
Placeholder for a DateTimeZone object with GMT as the time zone.
since |
11.1 |
---|
Type(s)
object
stz
Placeholder for a DateTimeZone object with the default server time zone as the time zone.
since |
11.1 |
---|
Type(s)
object
offsets
An array of offsets and time zone strings representing the available options from Joomla! CMS 1.5 and below.
deprecated |
12.1 |
---|---|
since |
11.1 |
Type(s)
array
_tz
The DateTimeZone object for usage in rending dates as strings.
since |
11.1 |
---|
Type(s)
object