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.

  • property-read: string $daysinmonth: t - Number of days in the given month.
  • property-read: string $dayofweek: N - ISO-8601 numeric representation of the day of the week.
  • property-read: string $dayofyear: z - The day of the year (starting from 0).
  • property-read: boolean $isleapyear: L - Whether it's a leap year.
  • property-read: string $day: d - Day of the month, 2 digits with leading zeros.
  • property-read: string $hour: H - 24-hour format of an hour with leading zeros.
  • property-read: string $minute: i - Minutes with leading zeros.
  • property-read: string $second: s - Seconds with leading zeros.
  • property-read: string $month: m - Numeric representation of a month, with leading zeros.
  • property-read: string $ordinal: S - English ordinal suffix for the day of the month, 2 characters.
  • property-read: string $week: W - Numeric representation of the day of the week.
  • property-read: string $year: Y - A full numeric representation of a year, 4 digits.
  • since: 11.1

Located in /libraries/joomla/date/date.php (line 33)

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 object $stz
 DateTimeZone $tz
Method Summary
 static JDate getInstance ([string $date = 'now'], [mixed $tz = null])
 string calendar (string $format, [boolean $local = false], [boolean $translate = true])
 string dayToString (integer $day, [boolean $abbr = false])
 JDate __construct ([string $date = 'now'], [mixed $tz = null])
 string format (string $format, [boolean $local = false], [boolean $translate = true])
 float getOffsetFromGMT ([boolean $hours = false])
 string monthToString (integer $month, [boolean $abbr = false])
 JDate setTimezone (DateTimeZone $tz)
 string toISO8601 ([boolean $local = false])
 string toRFC822 ([boolean $local = false])
 string toSql ([boolean $local = false], [JDatabaseDriver $db = null])
 integer toUnix ()
 mixed __get (string $name)
 string __toString ()
Variables
static string $format = 'Y-m-d H:i:s' (line 46)

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

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

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

  • since: 11.1
  • access: protected
static object $stz (line 63)

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

  • since: 11.1
  • access: protected
DateTimeZone $tz (line 71)

The DateTimeZone object for usage in rending dates as strings.

  • since: 12.1
  • access: protected
Methods
static getInstance (line 214)

Proxy for new JDate().

  • 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.
calendar (line 261)

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 229)

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?
Constructor __construct (line 81)

Constructor.

  • since: 11.1
  • 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. Might be a string or a DateTimeZone object.

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

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 338)

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 353)

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
setTimezone (line 394)

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

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

Redefinition of:
DateTime::setTimezone ( $timezone )
toISO8601 (line 412)

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.
toRFC822 (line 449)

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 428)

Gets the date as an SQL datetime string.

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

Gets the date as UNIX time stamp.

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

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 199)

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 35)
DAY_NAME = "\x022\x03" (line 36)
MONTH_ABBR = "\x023\x03" (line 37)
MONTH_NAME = "\x024\x03" (line 38)

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 Tue, 19 Nov 2013 14:57:55 +0100 by phpDocumentor 1.4.3