Scorpio System Date Time object; is an extension of the PHP DateTime object providing additional functionality above what the internal object allows.
systemDateTime supports the Serializable interface allowing the datetime object to be easily stored with both the date and the timezone which prevents errors when trying to restore the datetime.
public __construct([$inTime = 'now'], [$inTimezone = null])
Returns new DateTime object, if $inTimezone is not specified, defaults to system config timezone $inTimezone can be the string of the timezone; this will be checked against the valid strings
public __toString()
Returns the current date/time object as a string in Y-m-d H:i:s format
public serialize()
Implementation for Serializable interface
Returns an associative array containing date - the current datetime in standard CCYY-MM-DD HH:ii:ss format and timezone - the string name of the current timezone.
public unserialize($serialized)
Restores a serialized DateTime object
public static getInstance([$inTime = 'now'], [$inTimezone = null])
Returns an instance of systemDateTime object
public static getInstanceUtc([$inTime = 'now'])
Convenience method that creates an object with timezone set to UTC
public static getInstanceFromUnix($inTimestamp, [$inTimezone = null])
Returns new systemDateTime object from the UNIX timestamp
public static getDiffInSeconds($inDiff)
Returns the DateInterval in seconds
Note: DateInterval has no concept of dates so a year is treated as 365 days, a month 30 days etc. This may give strange results.
public modify($inModify)
Alter the timestamp by incrementing or decrementing in a format accepted by strtotime().
public setTimezone($inTimezone)
Set the timezone to $inTimezone
public setDate([$inYear = null], [$inMonth = null], [$inDay = null])
Set the date to that specified
public setTime([$inHours = null], [$inMinutes = null], [$inSeconds = null])
Set the time to that specified
public setTimestamp($inTimestamp)
Sets the date and time based on an Unix timestamp
public format($inFormat)
Returns the current date/time formatted according to $inFormat, returns false on bad format
public cloneDateTime()
Clones the current object, returning it for use in computations
public isModified()
Returns true if the object has been modified
public setModified([$inStatus = true])
Sets the objects modified status flag
public getDate()
Returns the date in CCYY-MM-DD format
public getYear()
Returns just the year, CCYY
public getMonth()
Returns the month with leading zero
public getMonthAsString([$inLong = false])
Returns the month as a string, if $inLong is true, returns long format
public getDay()
Returns the day with leading zero
public getDayAsString([$inLong = false])
Returns the day as a string, if $inLong is true, returns long format
public getTime()
Returns the time in 24-hour format
public getHour()
Returns the hour in 24-hour format
public getMinute()
Returns the minute with leading zero
public getSecond()
Returns the second with leading zero
public getWeekNumber()
Returns the week number
public getDayOfYear()
Returns the day of the year starting from 0 to 365
public toUnix()
Returns current date/time in Unix format
public toString()
Returns the date as a string (calls into systemDateTime::__toString()
public calc($inCalcString)
Creates a clone of the current object, and modifies it by $inCalcString. $inCalcString is any valid strtotime string
Tags: datetime, serializable, system, systemdatetime,
system Articles