Class QDateTime
QDateTime This DateTime class provides a nice wrapper around the PHP DateTime class, which is included with all versions of PHP >= 5.2.0. It includes many enhancements, including the ability to specify a null date or time portion to represent a date only or time only object. Inherits from the php DateTime object, and the built-in methods are available for you to call as well. In particular, note that the built-in format, and the qFormat routines here take different specifiers. Feel free to use either.
- DateTime implements DateTimeInterface
- QDateTime implements JsonSerializable
public static
|
|
public static
string
|
#
NowToString( string|null $strFormat = null )
Return Now as a string. Uses the default datetime format if none speicifed. |
public
boolean
|
|
public
boolean
|
|
public
boolean
|
|
public
string
|
|
public
array
|
|
public static
|
#
FromTimestamp( integer $intTimestamp, DateTimeZone $objTimeZone = null )
Create from a unix timestamp. Improves over php by taking into consideration the timezone, so that the internal format is automatically converted to the internal timezone, or the default timezone. |
public
|
#
__construct( null|integer|string|
Construct a QDateTime. Does a few things differently than the php version: - Always stores timestamps in local or given timezone, so time extraction is easy - Has settings to determine if you want a date only or time only type - Will NOT throw exceptions. Errors simply result in a null datetime. |
public static
|
#
LastDayOfTheMonth( integer $intMonth, integer $intYear )
Returns a new QDateTime object set to the last day of the specified month. |
public static
|
#
FirstDayOfTheMonth( integer $intMonth, integer $intYear )
Returns a new QDateTime object set to the first day of the specified month. |
public
string
|
|
public
|
|
public
|
|
public
string
|
|
public
|
#
setTime( integer|
Sets the time portion to the given time. If a QDateTime is given, will use the time portion of that object. Works around a problem in php that if you set the time across a daylight savings time boundary, the timezone does not advance. This version will detect that and advance the timezone. |
public
|
|
protected
|
|
public
|
#
ConvertToTimezone( string $strTimezoneIdentifier )
Converts the current QDateTime object to a different TimeZone. |
public
boolean
|
|
public
boolean
|
#
IsEarlierThan(
Returns true if current date time is earlier than the given one. |
public
boolean
|
#
IsEarlierOrEqualTo(
Returns true if current date time is earlier than the given one. |
public
boolean
|
#
IsLaterThan(
Returns true if current date time is later than the given one. |
public
boolean
|
#
IsLaterOrEqualTo(
Returns true if current date time is later than or equal to the given one. |
public
integer
|
|
public
|
#
Difference(
Returns the difference as a QDateSpan, which is easier to work with and more full featured than the php DateTimeInterval class. |
public
|
|
public
|
#
AddSeconds( integer $intSeconds )
Add a number of seconds. Use negative value to go earlier in time. |
public
|
|
public
|
|
public
QDateTIme
|
|
public
|
|
public
|
|
public
|
|
public
string
|
#
toJsObject( )
Convert the object to a javascript object. This is code that if executed in javascript would produce a Date javascript object. Note that the date will be created in the browser's local timezone, so convert to the browser's timezone first if that is important for you. |
public
array|mixed;
|
#
jsonSerialize( )
Returns a datetime in a way that it will pass through a json_encode and be decodalbe in qcubed.js. qcubed.unpackParams looks for this. |
public
|
|
public
mixed
|
__set_state(),
add(),
createFromFormat(),
diff(),
format(),
getLastErrors(),
getOffset(),
getTimestamp(),
getTimezone(),
modify(),
setISODate(),
setTimestamp(),
setTimezone(),
sub()
|
string |
Now
Used to specify the time right now (used when creating new instances of this class) |
#
'now'
|
string |
FormatIso
Date and time in ISO format |
#
'YYYY-MM-DD hhhh:mm:ss'
|
string |
FormatIsoCompressed
Date and time in ISO compressed format |
#
'YYYYMMDDhhhhmmss'
|
string |
FormatDisplayDate
Format used for displaying short date |
#
'MMM DD YYYY'
|
string |
FormatDisplayDateFull
Format used for displaying the full date |
#
'DDD, MMMM D, YYYY'
|
string |
FormatDisplayDateTime
Format used for displaying the short date and time |
#
'MMM DD YYYY hh:mm zz'
|
string |
FormatDisplayDateTimeFull
Format used for displaying the full date and time |
#
'DDDD, MMMM D, YYYY, h:mm:ss zz'
|
string |
FormatDisplayTime
Format to display only the time |
#
'hh:mm:ss zz'
|
string |
FormatRfc822
Date and time format according to RFC 822 |
#
'DDD, DD MMM YYYY hhhh:mm:ss ttt'
|
string |
FormatRfc5322
Date and time format according to RFC 5322 |
#
'DDD, DD MMM YYYY hhhh:mm:ss ttttt'
|
string |
FormatSoap
Format used to represent date for SOAP |
#
'YYYY-MM-DDThhhh:mm:ss'
|
integer |
UnknownType
Unknown type interpretation |
#
0
|
integer |
DateOnlyType
Interpret as only date (used in QDateTimePicket and MySqli database type) |
#
1
|
integer |
TimeOnlyType
Interpret as only time (used in QDateTimePicket and MySqli database type) |
#
2
|
integer |
DateAndTimeType
Interpret as both date and type (used in QDateTimePicket and MySqli database type) |
#
3
|
ATOM,
COOKIE,
ISO8601,
RFC1036,
RFC1123,
RFC2822,
RFC3339,
RFC822,
RFC850,
RSS,
W3C
|
protected
boolean
|
$blnDateNull
true if date is null |
#
true
|
protected
boolean
|
$blnTimeNull
true if time is null, rather than just zero (beginning of day) |
#
true
|
public static
string
|
$DefaultFormat
The "Default" Display Format |
|
public static
string
|
$DefaultTimeFormat
The "Default" Display Format for Times |
|
public static
string
|
$DefaultDateOnlyFormat
The "Default" Display Format for Dates with null times |
|
protected
|
$strSerializedData
The following code is a workaround for a PHP bug in 5.2 and greater (at least to 5.4). |
|
protected
|
$strSerializedTZ
|
public
null|integer
|
$Month
|
public
null|integer
|
$Day
|
public
null|integer
|
$Year
|
public
null|integer
|
$Hour
|
public
null|integer
|
$Minute
|
public
null|integer
|
$Second
|
public
integer
|
$Timestamp
|
public read-only
string
|
$Age
A string representation of the age relative to now. |
public read-only
|
$LastDayOfTheMonth
A new QDateTime representing the last day of this date's month. |
public read-only
|
$FirstDayOfTheMonth
A new QDateTime representing the first day of this date's month. |