Class JDate

Description

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

  • since: 11.1

Located in /libraries/joomla/utilities/date.php (line 20)

DateTime
   |
   --JDate
Class Constant Summary
DAY_ABBR = "\x021\x03"
DAY_NAME = "\x022\x03"
MONTH_ABBR = "\x023\x03"
MONTH_NAME = "\x024\x03"
Variable Summary
static string $format
static object $gmt
static array $offsets
static object $stz
object $_tz
Method Summary
static JDate getInstance ([string $date = 'now'], [mixed $tz = null])
JDate __construct ([string $date = 'now'], [mixed $tz = null])
string calendar (string $format, [boolean $local = false], [boolean $translate = true])
string dayToString (integer $day, [boolean $abbr = false])
string format (string $format, [boolean $local = false], [boolean $translate = true])
float getOffsetFromGMT ([boolean $hours = false])
string monthToString (integer $month, [boolean $abbr = false])
boolean setOffset (float $offset)
DateTimeZone setTimezone (object $tz)
string toFormat ([string $format = '%Y-%m-%d %H:%M:%S'], [boolean $local = false])
string toISO8601 ([boolean $local = false])
string toMySQL ([boolean $local = false])
string toRFC822 ([boolean $local = false])
string toSql ([boolean $local = false], [JDatabase $dbo = null])
integer toUnix ()
mixed __get (string $name)
string __toString ()
Variables
static string $format = 'Y-m-d H:i:s' (line 33)

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

  • since: 11.1
  • access: public
static object $gmt (line 41)

Placeholder for a DateTimeZone object with GMT as the time zone.

  • since: 11.1
  • access: protected
static array $offsets = array('-12' => 'Etc/GMT-12', '-11' => 'Pacific/Midway', '-10' => 'Pacific/Honolulu', '-9.5' => 'Pacific/Marquesas',
'-9' => 'US/Alaska', '-8' => 'US/Pacific', '-7' => 'US/Mountain', '-6' => 'US/Central', '-5' => 'US/Eastern', '-4.5' => 'America/Caracas',
'-4' => 'America/Barbados', '-3.5' => 'Canada/Newfoundland', '-3' => 'America/Buenos_Aires', '-2' => 'Atlantic/South_Georgia',
'-1' => 'Atlantic/Azores', '0' => 'Europe/London', '1' => 'Europe/Amsterdam', '2' => 'Europe/Istanbul', '3' => 'Asia/Riyadh',
'3.5' => 'Asia/Tehran', '4' => 'Asia/Muscat', '4.5' => 'Asia/Kabul', '5' => 'Asia/Karachi', '5.5' => 'Asia/Calcutta',
'5.75' => 'Asia/Katmandu', '6' => 'Asia/Dhaka', '6.5' => 'Indian/Cocos', '7' => 'Asia/Bangkok', '8' => 'Australia/Perth',
'8.75' => 'Australia/West', '9' => 'Asia/Tokyo', '9.5' => 'Australia/Adelaide', '10' => 'Australia/Brisbane',
'10.5' => 'Australia/Lord_Howe', '11' => 'Pacific/Kosrae', '11.5' => 'Pacific/Norfolk', '12' => 'Pacific/Auckland',
'12.75' => 'Pacific/Chatham', '13' => 'Pacific/Tongatapu', '14' => 'Pacific/Kiritimati')
(line 61)

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
  • access: protected
static object $stz (line 50)

Placeholder for a DateTimeZone object with the default server time zone as the time zone.

  • since: 11.1
  • access: protected
object $_tz (line 77)

The DateTimeZone object for usage in rending dates as strings.

  • since: 11.1
  • access: protected
Methods
static method getInstance (line 228)

Proxy for new JDate().

  • throws: JException
  • since: 11.3
  • access: public
static JDate getInstance ([string $date = 'now'], [mixed $tz = null])
  • string $date: String in a format accepted by strtotime(), defaults to "now".
  • mixed $tz: Time zone to be used for the date.
Constructor __construct (line 89)

Constructor.

  • since: 11.1
  • throws: JException
  • access: public
JDate __construct ([string $date = 'now'], [mixed $tz = null])
  • string $date: String in a format accepted by strtotime(), defaults to "now".
  • mixed $tz: Time zone to be used for the date.

Redefinition of:
DateTime::constructor __construct ( [$time = ], [$object = ] )
calendar (line 275)

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

  • return: The date string in the specified format format.
  • since: 11.1
  • access: public
string calendar (string $format, [boolean $local = false], [boolean $translate = true])
  • string $format: The date format specification string (see http://www.php.net/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
dayToString (line 243)

Translates day of week number to a string.

  • return: The day of the week.
  • since: 11.1
  • access: public
string dayToString (integer $day, [boolean $abbr = false])
  • integer $day: The numeric day of the week.
  • boolean $abbr: Return the abbreviated day string?
format (line 291)

Gets the date as a formatted string.

  • return: The date string in the specified format format.
  • since: 11.1
  • access: public
string format (string $format, [boolean $local = false], [boolean $translate = true])
  • string $format: The date format specification string (see http://www.php.net/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

Redefinition of:
DateTime::format ( $format )
getOffsetFromGMT (line 352)

Get the time offset from GMT in hours or seconds.

  • return: The time offset from GMT either in hours or in seconds.
  • since: 11.1
  • access: public
float getOffsetFromGMT ([boolean $hours = false])
  • boolean $hours: True to return the value in hours.
monthToString (line 367)

Translates month number to a string.

  • return: The month of the year.
  • since: 11.1
  • access: public
string monthToString (integer $month, [boolean $abbr = false])
  • integer $month: The numeric month of the year.
  • boolean $abbr: If true, return the abbreviated month string
setOffset (line 409)

Set the date offset (in hours).

  • return: True on success.
  • deprecated: 12.1 Use setTimezone instead.
  • since: 11.1
  • access: public
boolean setOffset (float $offset)
  • float $offset: The offset in hours.
setTimezone (line 435)

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

  • return: The old DateTimeZone object.
  • since: 11.1
  • access: public
DateTimeZone setTimezone (object $tz)
  • object $tz: The new DateTimeZone object.

Redefinition of:
DateTime::setTimezone ( $timezone )
toFormat (line 456)

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

  • return: The date as a formatted string.
  • deprecated: 12.1 Use JDate::format() instead.
  • deprecated: Use JDate::format() instead.
  • access: public
string toFormat ([string $format = '%Y-%m-%d %H:%M:%S'], [boolean $local = false])
  • string $format: The date format specification string (see http://www.php.net/strftime)
  • boolean $local: True to return the date string in the local time zone, false to return it in GMT.
toISO8601 (line 511)

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 toISO8601 ([boolean $local = false])
  • boolean $local: True to return the date string in the local time zone, false to return it in GMT.
toMySQL (line 527)

Gets the date as an MySQL datetime string.

string toMySQL ([boolean $local = false])
  • boolean $local: True to return the date string in the local time zone, false to return it in GMT.
toRFC822 (line 564)

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.

string toRFC822 ([boolean $local = false])
  • boolean $local: True to return the date string in the local time zone, false to return it in GMT.
toSql (line 544)

Gets the date as an SQL datetime string.

string toSql ([boolean $local = false], [JDatabase $dbo = null])
  • boolean $local: True to return the date string in the local time zone, false to return it in GMT.
  • JDatabase $dbo: The database driver or null to use JFactory::getDbo()
toUnix (line 576)

Gets the date as UNIX time stamp.

  • return: The date as a UNIX timestamp.
  • since: 11.1
  • access: public
integer toUnix ()
__get (line 139)

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

  • return: A value if the property name is valid, null otherwise.
  • since: 11.1
  • access: public
mixed __get (string $name)
  • string $name: The name of the property.
__toString (line 212)

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

  • return: The date as a formatted string.
  • since: 11.1
  • access: public
string __toString ()

Inherited Methods

Inherited From DateTime (Internal Class)

constructor __construct ( [$time = ], [$object = ] )
add ( $interval )
createFromFormat ( $format, $time, [$object = ] )
diff ( $object, [$absolute = ] )
format ( $format )
getLastErrors ( )
getOffset ( )
getTimestamp ( )
getTimezone ( )
modify ( $modify )
setDate ( $year, $month, $day )
setISODate ( $year, $week, [$day = ] )
setTime ( $hour, $minute, [$second = ] )
setTimestamp ( $unixtimestamp )
setTimezone ( $timezone )
sub ( $interval )
__set_state ( )
__wakeup ( )
Class Constants
DAY_ABBR = "\x021\x03" (line 22)
DAY_NAME = "\x022\x03" (line 23)
MONTH_ABBR = "\x023\x03" (line 24)
MONTH_NAME = "\x024\x03" (line 25)

Inherited Constants

Inherited from DateTime (Internal Class)

ATOM = 'Y-m-d\\TH:i:sP'
COOKIE = 'l, d-M-y H:i:s T'
ISO8601 = 'Y-m-d\\TH:i:sO'
RFC822 = 'D, d M y H:i:s O'
RFC850 = 'l, d-M-y H:i:s T'
RFC1036 = 'D, d M y H:i:s O'
RFC1123 = 'D, d M Y H:i:s O'
RFC2822 = 'D, d M Y H:i:s O'
RFC3339 = 'Y-m-d\\TH:i:sP'
RSS = 'D, d M Y H:i:s O'
W3C = 'Y-m-d\\TH:i:sP'

Documentation generated on Mon, 25 Jun 2012 13:54:03 -0500 by phpDocumentor 1.4.4