QCubed - A PHP5 rapid development MVC framework.
Home  |  Updates

classQDateTime

QDateTime Class Reference

Inherits QBaseClass.

Collaboration diagram for QDateTime:

List of all members.

Public Member Functions

Static Public Member Functions

Public Attributes

Static Public Attributes

Protected Member Functions

Protected Attributes


Detailed Description

QDateTime (Standard) REQUIRES: PHP >= 5.2.0

This DateTime class manages datetimes for the entire system. It basically provides a nice wrapper around the PHP DateTime class, which is included with all versions of PHP >= 5.2.0.

For legacy PHP users (PHP < 5.2.0), please refer to QDateTime.legacy

QDateTime.legacy

This DateTime class manages datetimes for the entire system. It basically provides a nice wrapper around the built-in date-related functionality in PHP.

This is used by QCubed users using PHP < 5.2.0 As of Qcodo 0.3.14, no additional functionality will be added to QDateTime.legacy

All new QDateTime functionality will be added to the QDateTime (standard) which uses PHP DateTime, which is included in all versions of >= PHP 5.2.0


Constructor & Destructor Documentation

QDateTime::__construct ( mixValue = null,
DateTimeZone $  objTimeZone = null 
)

References format(), and Now.

Referenced by __wakeup().

QDateTime::__construct ( mixValue = null  ) 

Constructor function to create a new datetime. Takes in an optional $mixValue, which can be one of the following: ISO Standard format (mostly used in databases) 1977-03-20 15:35:15 ISO-compressed format (the pure digits of the ISO format) 19770320153515 another DateTime object (to clone it) the QDateTime::Now constant (to return current date/time) a unix timestamp null/none (to return a blank date, which by default is set to 0000-01-01 00:00:00) DateTime can be constructed with either the date, the time, or both portions of any of the above formats. For any part that's missing, the date would be set to 0000-01-01, or the time would be set to 00:00:00

Parameters:
$mixValue the date/time to set (see documentation for more information)
Returns:
DateTime the new DateTime object

References Now.


Member Function Documentation

QDateTime::__get ( strName  ) 

Override method to perform a property "Get" This will get the value of $strName

Parameters:
string $strName Name of the property to get
Returns:
mixed the returned property

Reimplemented from QBaseClass.

References __get(), Difference(), QCallerException::IncrementOffset(), and Now.

QDateTime::__get ( strName  ) 

Override method to perform a property "Get" This will get the value of $strName All inhereted objects that call __get() should always fall through to calling parent::__get() in a try/catch statement catching for CallerExceptions.

Parameters:
string $strName Name of the property to get
Returns:
mixed the returned property

Reimplemented from QBaseClass.

References Difference(), format(), Now, and ReinforceNullProperties().

Referenced by __get().

QDateTime::__set ( strName,
mixValue 
)

Override method to perform a property "Set" This will set the property $strName to be $mixValue

Parameters:
string $strName Name of the property to set
string $mixValue New value of the property
Returns:
mixed the property that was set

Reimplemented from QBaseClass.

References QType::Cast(), QCallerException::IncrementOffset(), and QType::Integer.

QDateTime::__set ( strName,
mixValue 
)

Override method to perform a property "Set" This will set the property $strName to be $mixValue All inhereted objects that call __set() should always fall through to calling parent::__set() in a try/catch statement catching for CallerExceptions.

Parameters:
string $strName Name of the property to set
string $mixValue New value of the property
Returns:
mixed the property that was set

Reimplemented from QBaseClass.

References QType::Cast(), QCallerException::IncrementOffset(), QType::Integer, ReinforceNullProperties(), setDate(), and setTime().

QDateTime::__sleep (  ) 

References format().

QDateTime::__toString ( strFormat = null  ) 

Outputs the date as a string given the format strFormat. By default, it will return as QDateTime::FormatDisplayDate "MMM DD YYYY", e.g. Mar 20 1977.

Properties of strFormat are (using Sunday, March 2, 1977 at 1:15:35 pm in the following examples):

M - Month as an integer (e.g., 3) MM - Month as an integer with leading zero (e.g., 03) MMM - Month as three-letters (e.g., Mar) MMMM - Month as full name (e.g., March)

D - Day as an integer (e.g., 2) DD - Day as an integer with leading zero (e.g., 02) DDD - Day of week as three-letters (e.g., Wed) DDDD - Day of week as full name (e.g., Wednesday)

YY - Year as a two-digit integer (e.g., 77) YYYY - Year as a four-digit integer (e.g., 1977)

h - Hour as an integer in 12-hour format (e.g., 1) hh - Hour as an integer in 12-hour format with leading zero (e.g., 01) hhh - Hour as an integer in 24-hour format (e.g., 13) hhhh - Hour as an integer in 24-hour format with leading zero (e.g., 13)

mm - Minute as a two-digit integer

ss - Second as a two-digit integer

z - "pm" or "am" zz - "PM" or "AM" zzz - "p.m." or "a.m." zzzz - "P.M." or "A.M."

ttt - Timezone as a three-letter code (e.g. GMT)

Parameters:
string $strFormat the format of the date
Returns:
string the formatted date as a string

References $DefaultFormat.

QDateTime::__toString ( strFormat = null  ) 

Outputs the date as a string given the format strFormat. By default, it will return as QDateTime::FormatDisplayDate "MMM DD YYYY", e.g. Mar 20 1977.

Properties of strFormat are (using Sunday, March 2, 1977 at 1:15:35 pm in the following examples):

M - Month as an integer (e.g., 3) MM - Month as an integer with leading zero (e.g., 03) MMM - Month as three-letters (e.g., Mar) MMMM - Month as full name (e.g., March)

D - Day as an integer (e.g., 2) DD - Day as an integer with leading zero (e.g., 02) DDD - Day of week as three-letters (e.g., Wed) DDDD - Day of week as full name (e.g., Wednesday)

YY - Year as a two-digit integer (e.g., 77) YYYY - Year as a four-digit integer (e.g., 1977)

h - Hour as an integer in 12-hour format (e.g., 1) hh - Hour as an integer in 12-hour format with leading zero (e.g., 01) hhh - Hour as an integer in 24-hour format (e.g., 13) hhhh - Hour as an integer in 24-hour format with leading zero (e.g., 13)

mm - Minute as a two-digit integer

ss - Second as a two-digit integer

z - "pm" or "am" zz - "PM" or "AM" zzz - "p.m." or "a.m." zzzz - "P.M." or "A.M."

ttt - Timezone as a three-letter code (e.g. GMT)

Parameters:
string $strFormat the format of the date
Returns:
string the formatted date as a string

References $DefaultFormat, format(), and ReinforceNullProperties().

QDateTime::__wakeup (  ) 

References __construct().

QDateTime::Add ( QDateTimeSpan dtsSpan  ) 

QDateTime::Add ( QDateTimeSpan dtsSpan  ) 

QDateTime::AddDays ( intDays  ) 

QDateTime::AddHours ( intHours  ) 

QDateTime::AddMinutes ( intMinutes  ) 

QDateTime::AddMonths ( intMonths  ) 

QDateTime::AddSeconds ( intSeconds  ) 

QDateTime::AddYears ( intYears  ) 

QDateTime::Difference ( QDateTime dttDateTime  ) 

QDateTime::Difference ( QDateTime dttDateTime  ) 

QDateTime::format ( strFormat  ) 

static QDateTime::FromTimestamp ( intTimestamp  )  [static]

Parameters:
integer $intTimestamp
Returns:
QDateTime

static QDateTime::FromTimestamp ( intTimestamp,
DateTimeZone $  objTimeZone = null 
) [static]

Parameters:
integer $intTimestamp
DateTimeZone $objTimeZone
Returns:
QDateTime

Referenced by QCalendarPopup::__get(), QCalendarPopup::GetControlHtml(), and QCalendarPopup::ParsePostData().

QDateTime::GetSoapDateTimeArray ( dttArray  ) 

This returns an array of strings with ISO-formatted datetime values, given an array of QDateTime objects

Returns:
string[] array of ISO-formatted datetime strings

References FormatSoap.

QDateTime::GetSoapDateTimeArray ( dttArray  ) 

References FormatSoap.

QDateTime::IsDateNull (  ) 

This returns a boolean specifying whether or not the Date portion is null

Returns:
boolean whether or not the date is null

QDateTime::IsDateNull (  ) 

QDateTime::IsEarlierOrEqualTo ( QDateTime dttCompare  ) 

QDateTime::IsEarlierThan ( QDateTime dttDate  ) 

QDateTime::IsEarlierThan ( QDateTime dttCompare  ) 

QDateTime::IsEqualTo ( QDateTime dttDate  ) 

QDateTime::IsEqualTo ( QDateTime dttCompare  ) 

QDateTime::IsLaterOrEqualTo ( QDateTime dttCompare  ) 

QDateTime::IsLaterThan ( QDateTime dttDate  ) 

QDateTime::IsLaterThan ( QDateTime dttCompare  ) 

QDateTime::IsNull (  ) 

This returns a boolean specifying whether or not this object DateTime is null

Returns:
boolean whether or not the datetime object is null

QDateTime::IsNull (  ) 

QDateTime::IsTimeNull (  ) 

This returns a boolean specifying whether or not the Date portion is null

Returns:
boolean whether or not the time is null

QDateTime::IsTimeNull (  ) 

QDateTime::Modify ( mixValue  ) 

static QDateTime::Now ( blnTimeValue = true  )  [static]

Returns a new QDateTime object that's set to "Now" Set blnTimeValue to true (default) for a DateTime, and set blnTimeValue to false for just a Date

Parameters:
boolean $blnTimeValue whether or not to include the time value
Returns:
QDateTime the current date and/or time

References Now.

static QDateTime::Now ( blnTimeValue = true  )  [static]

Returns a new QDateTime object that's set to "Now" Set blnTimeValue to true (default) for a DateTime, and set blnTimeValue to false for just a Date

Parameters:
boolean $blnTimeValue whether or not to include the time value
Returns:
QDateTime the current date and/or time

References Now.

static QDateTime::NowToString ( strFormat = null  )  [static]

Shortcut to output the current datetime in any defined format. Follows the same formatting mechanism as __toString. This is basically a shortcut to doing: $dttNow = new QDateTime(QDateTime::Now); $dttNow->__toString($strFormat);

Parameters:
string $strFormat the format of the datetime
Returns:
string the formatted current datetime as a string

References $DefaultFormat, and Now.

static QDateTime::NowToString ( strFormat = null  )  [static]

References Now.

Referenced by QEmailServer::Send().

QDateTime::PHPDate ( strFormat  ) 

This makes a call to the PHP date() function, where you can pass in a PHP date()-compatible format to display this date/time object.

Parameters:
string $strFormat a PHP date()-compatible string format for datetime
Returns:
string the output from the PHP date() call

QDateTime::PhpDate ( strFormat  ) 

References format().

QDateTime::ReinforceNullProperties (  )  [protected]

References setDate(), and setTime().

Referenced by __get(), __set(), __toString(), and format().

QDateTime::setDate ( intYear,
intMonth,
intDay 
)

Parameters:
integer $intYear
integer $intMonth
integer $intDay

References $intDay, $intMonth, $intYear, QType::Cast(), QCallerException::IncrementOffset(), and QType::Integer.

QDateTime::setDate ( intYear,
intMonth,
intDay 
)

QDateTime::setTime ( intHour,
intMinute,
intSecond 
)

Parameters:
integer $intHour
integer $intMinute
integer $intSecond

References $intHour, $intMinute, $intSecond, QType::Cast(), QCallerException::IncrementOffset(), and QType::Integer.

QDateTime::setTime ( intHour,
intMinute,
intSecond 
)

QDateTime::Subtract ( QDateTimeSpan dtsSpan  ) 


Member Data Documentation

QDateTime::$blnDateNull = true [protected]

QDateTime::$blnTimeNull = true [protected]

QDateTime::$DefaultFormat = QDateTime::FormatDisplayDate [static]

Referenced by __toString(), and NowToString().

QDateTime::$intDay [protected]

Referenced by setDate().

QDateTime::$intHour [protected]

Referenced by setTime().

QDateTime::$intMinute [protected]

Referenced by setTime().

QDateTime::$intMonth [protected]

Referenced by setDate().

QDateTime::$intSecond [protected]

Referenced by setTime().

QDateTime::$intYear [protected]

Referenced by setDate().

QDateTime::$strSerializedData [protected]

const QDateTime::FormatDisplayDate = 'MMM DD YYYY'

Constant for __toString to display Date as simple Mar 20 1977

Referenced by QCalendarPopup::GetControlHtml().

const QDateTime::FormatDisplayDateFull = 'DDD, MMMM D, YYYY'

Constant for __toString to display Date as extended Sunday, March 20, 1977

const QDateTime::FormatDisplayDateTime = 'MMM DD YYYY hh:mm zz'

Constant for __toString to display Date/Time as simple Mar 20 1977 03:35 PM

const QDateTime::FormatDisplayDateTimeFull = 'DDDD, MMMM D, YYYY, h:mm:ss zz'

Constant for __toString to display Date/Time as extended Sunday, March 20, 1977, 3:35:15 PM

const QDateTime::FormatDisplayTime = 'hh:mm:ss zz'

Constant for __toString to display Time as 03:35:15 PM

const QDateTime::FormatIso = 'YYYY-MM-DD hhhh:mm:ss'

Constant for __toString to display Date/Time as ISO Standard 1977-03-20 15:35:15

Referenced by QDatabaseBase::SqlVariable(), QSqlServerDatabase::SqlVariable(), and QPostgreSqlDatabase::SqlVariable().

const QDateTime::FormatIsoCompressed = 'YYYYMMDDhhhhmmss'

Constant for __toString to display Date/Time as 14-digit 19770320153515

const QDateTime::FormatRfc822 = 'DDD, DD MMM YYYY hhhh:mm:ss ttt'

Constant for __toString to display DateTime as RFC 822 Format Sun, 20 Mar 1977 15:35:15 GMT

Referenced by QRssItem::GetXml(), QRssFeed::GetXml(), and QEmailServer::Send().

const QDateTime::FormatSoap = 'YYYY-MM-DDThhhh:mm:ss'

Constant for __toString to display Date/Time as SOAP Standard 1977-03-20T15:35:15

Referenced by GetSoapDateTimeArray().

const QDateTime::Now = 'now'

Pass this to __construct in order to set DateTime to current date/time. e.g. $dttDate = new QDateTime(QDateTime::Now);

Referenced by __construct(), __get(), QDateTimeTextBox::__set(), Now(), NowToString(), and QDateTimeTextBox::Validate().


The documentation for this class was generated from the following files: