Back to Joomla project (class list)

Class Date - list of methods

Date is a class that stores a date and provides logic to manipulate and render that date in a variety of formats.
Package: Joomla\CMS\Date
Copyright: (C) 2006 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
Located at: Joomla/Date/Date.php
Project: Joomla

Method Summary

public
(mixed $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. Might be a string or a DateTimeZone object.
Since
  • 1.7.0
Show source code of this method: __construct Source Code

public mixed
(mixed $name)

Magic method to access properties of the date given by class to the format method.
Parameters
  • string $name The name of the property.
Returns
  • mixed A value if the property name is valid, null otherwise.
Since
  • 1.7.0
Show source code of this method: __get Source Code

public string
()

Magic method to render the date object in the format specified in the public static member Date::$format.
Returns
  • string The date as a formatted string.
Since
  • 1.7.0
Show source code of this method: __toString Source Code

public static \Joomla\CMS\Date\Date
(mixed $date = 'now', mixed $tz = null)

Proxy for new Date().
Parameters
  • string $date String in a format accepted by strtotime(), defaults to "now".
  • mixed $tz Time zone to be used for the date.
Returns
  • \Joomla\CMS\Date\Date
Since
  • 1.7.3
Show source code of this method: getInstance Source Code

public string
(mixed $day, mixed $abbr = false)

Translates day of week number to a string.
Parameters
  • int $day The numeric day of the week.
  • bool $abbr Return the abbreviated day string?
Returns
  • string The day of the week.
Since
  • 1.7.0
Show source code of this method: dayToString Source Code

public string
(mixed $format, mixed $local = false, mixed $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})
  • bool $local True to return the date string in the local time zone, false to return it in GMT.
  • bool $translate True to translate localised strings
Returns
  • string The date string in the specified format format.
Since
  • 1.7.0
Show source code of this method: calendar Source Code

public string
(mixed $format, mixed $local = false, mixed $translate = true)

Gets the date as a formatted string.
Parameters
  • string $format The date format specification string (see {@link PHP_MANUAL#date})
  • bool $local True to return the date string in the local time zone, false to return it in GMT.
  • bool $translate True to translate localised strings
Returns
  • string The date string in the specified format format.
Since
  • 1.7.0
Show source code of this method: format Source Code

public float
(mixed $hours = false)

Get the time offset from GMT in hours or seconds.
Parameters
  • bool $hours True to return the value in hours.
Returns
  • float The time offset from GMT either in hours or in seconds.
Since
  • 1.7.0
Show source code of this method: getOffsetFromGmt Source Code

public string
(mixed $month, mixed $abbr = false)

Translates month number to a string.
Parameters
  • int $month The numeric month of the year.
  • bool $abbr If true, return the abbreviated month string
Returns
  • string The month of the year.
Since
  • 1.7.0
Show source code of this method: monthToString Source Code

public \Joomla\CMS\Date\Date
(mixed $tz)

Method to wrap the setTimezone() function and set the internal time zone object.
Parameters
  • \DateTimeZone $tz The new \DateTimeZone object.
Returns
  • \Joomla\CMS\Date\Date
Since
  • 1.7.0
-
  • This method can't be type hinted due to a PHP bug: https://bugs.php.net/bug.php?id=61483
Show source code of this method: setTimezone Source Code

public string
(mixed $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
  • bool $local True to return the date string in the local time zone, false to return it in GMT.
Returns
  • string The date string in ISO 8601 format.
Since
  • 1.7.0
-
  • http://www.ietf.org/rfc/rfc3339.txt
Show source code of this method: toISO8601 Source Code

public string
(mixed $local = false, \Joomla\Database\DatabaseDriver $db = null)

Gets the date as an SQL datetime string.
Parameters
  • bool $local True to return the date string in the local time zone, false to return it in GMT.
  • \Joomla\Database\DatabaseDriver $db The database driver or null to use Factory::getDbo()
Returns
  • string The date string in SQL datetime format.
Since
  • 2.5.0
-
  • http://dev.mysql.com/doc/refman/5.0/en/datetime.html
Show source code of this method: toSql Source Code

public string
(mixed $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
  • bool $local True to return the date string in the local time zone, false to return it in GMT.
Returns
  • string The date string in RFC 822 format.
Since
  • 1.7.0
-
  • http://www.ietf.org/rfc/rfc2822.txt
Show source code of this method: toRFC822 Source Code

public int
()

Gets the date as UNIX time stamp.
Returns
  • int The date as a UNIX timestamp.
Since
  • 1.7.0
Show source code of this method: toUnix Source Code

Properties Summary

public static string
$format
The format string to be applied when using the __toString() magic method.
Since
  • 1.7.0
protected static object
$gmt
Placeholder for a \DateTimeZone object with GMT as the time zone.
Since
  • 1.7.0
-
  • object
protected static object
$stz
Placeholder for a \DateTimeZone object with the default server time zone as the time zone.
Since
  • 1.7.0
-
  • object
protected \DateTimeZone
$tz
The \DateTimeZone object for usage in rending dates as strings.
Since
  • 3.0.0

Tags Summary

public \Joomla\CMS\Date\Date|bool
add (\DateInterval $interval)
Adds an amount of days, months, years, hours, minutes and seconds to a Date object.
public \Joomla\CMS\Date\Date|bool
sub (\DateInterval $interval)
Subtracts an amount of days, months, years, hours, minutes and seconds from a Date object.
public \Joomla\CMS\Date\Date|bool
modify (string $modify)
Alter the timestamp of this object by incre/decre-menting in a format accepted by strtotime().
ready-only string
$daysinmonth
t - Number of days in the given month.
ready-only string
$dayofweek
N - ISO-8601 numeric representation of the day of the week.
ready-only string
$dayofyear
z - The day of the year (starting from 0).
ready-only bool
$isleapyear
L - Whether it's a leap year.
ready-only string
$day
d - Day of the month, 2 digits with leading zeros.
ready-only string
$hour
H - 24-hour format of an hour with leading zeros.
ready-only string
$minute
i - Minutes with leading zeros.
ready-only string
$second
s - Seconds with leading zeros.
ready-only string
$microsecond
u - Microseconds with leading zeros.
ready-only string
$month
m - Numeric representation of a month, with leading zeros.
ready-only string
$ordinal
S - English ordinal suffix for the day of the month, 2 characters.
ready-only string
$week
W - ISO-8601 week number of year, weeks starting on Monday.
ready-only string
$year
Y - A full numeric representation of a year, 4 digits.
Since
1.7.0