Properties

$value

$value : null|\DateTime

Type

null|\DateTime

$defaultTimezone

$defaultTimezone : null|\DateTimeZone

This is the default timezone. It's set to the servers timezone.

This object is static because we don't want to detect the default timezone each time.

Type

null|\DateTimeZone

$defaultFormat

$defaultFormat : string

Default date format

Type

string

$timezone

$timezone : \app\framework\Component\StdLib\StdObject\DateTimeObject\Timezone

Type

\app\framework\Component\StdLib\StdObject\DateTimeObject\Timezone — of entry date timestamp.

$format

$format : string

Type

string — Date format

Methods

isLeap()

isLeap() : string

Check if current DateTimeObject is a leap year.

Returns

string —

Boolean true if it's a leap year.

isFuture()

isFuture() : boolean

Check if current DateTimeObject is in future.

Returns

boolean —

Boolean true if the date is in the future. Otherwise false.

isPast()

isPast() : boolean

Check if current DateTimeObject is in past.

Returns

boolean —

Boolean true if the date is in the past. Otherwise false.

largerThan()

largerThan(integer|string|\DateTime|\app\framework\Component\StdLib\StdObject\DateTimeObject\DateTimeObject  $time) : boolean

Check if current datetime is larger than $time.

Parameters

integer|string|\DateTime|\app\framework\Component\StdLib\StdObject\DateTimeObject\DateTimeObject $time

Date to compare to.

Returns

boolean —

Boolean true if current date object is larger than the provided $time.

smallerThan()

smallerThan(integer|string|\DateTime|\app\framework\Component\StdLib\StdObject\DateTimeObject\DateTimeObject  $time) : boolean

Check if current datetime smaller than $time.

Parameters

integer|string|\DateTime|\app\framework\Component\StdLib\StdObject\DateTimeObject\DateTimeObject $time

Date to compare to.

Returns

boolean —

Boolean true if current date object is smaller than the provided $time.

add()

add(string  $amount) : $this

Adds an amount of days, months, years, hours, minutes and seconds to a DateTimeObject.

Parameters

string $amount

You can specify the amount in ISO8601 format (example: 'P14D' = 14 days; 'P1DT12H' = 1 day 12 hours), or as a date string (example: '1 day', '2 months', '3 year', '2 days + 10 minutes').

Returns

$this

setDate()

setDate(integer  $year, integer  $month, integer  $day) : $this

Set the date on current object.

Parameters

integer $year
integer $month
integer $day

Returns

$this

setTime()

setTime(integer  $hour, integer  $minute, integer  $second) : $this

Set the time on current object.

Parameters

integer $hour
integer $minute
integer $second

Returns

$this

setTimestamp()

setTimestamp(integer  $timestamp) : $this

Set the timestamp on current object.

Parameters

integer $timestamp

UNIX timestamp.

Returns

$this

sub()

sub(string  $amount) : $this

Subtracts an amount of days, months, years, hours, minutes and seconds from current DateTimeObject.

Parameters

string $amount

You can specify the amount in ISO8601 format (example: 'P14D' = 14 days; 'P1DT12H' = 1 day 12 hours), or as a date string (example: '1 day', '2 months', '3 year', '2 days + 10 minutes').

Returns

$this

offsetToTimezone()

offsetToTimezone(string|\DateTimeZone  $timezone) : $this

Offsets the date object from current timezone to defined $timezone.

This is an alias of DateTimeObject::setTimezone.

Parameters

string|\DateTimeZone $timezone

Timezone to which you wish to offset. You can either pass \DateTimeZone object or a valid timezone string. For timezone string formats visit: http://php.net/manual/en/timezones.php

Returns

$this

val()

val(null  $value = null) : mixed

Return, or update, current standard objects value.

Parameters

null $value

If $value is set, value is updated and DateTimeObject is returned.

Returns

mixed

exception()

exception(  $message) 

Throw a standard object exception.

Parameters

$message

Throws

\app\framework\Component\StdLib\StdObject\StdObjectException

isSerialized()

isSerialized(string  $value, mixed  $result = null) : boolean

Checks if a string is serialized using quick string manipulation to throw out obviously incorrect strings. Unserialize is then run on the string to perform the final verification.

Valid serialized forms are the following:

  • boolean: b:1;
  • integer: i:1;
  • double: d:0.2;
  • string: s:4:"test";
  • array: a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}
  • object: O:8:"stdClass":0:{}
  • null: N;

Parameters

string $value

Value to test for serialized form

mixed $result

Result of unserialize() of the $value

Returns

boolean —

True if $value is serialized data, otherwise false

setTimezone()

setTimezone(string|\DateTimeZone  $timezone) : $this

Set a new timezone for current date object.

NOTE: The current timestamp will be recalculated with the offset of current timezone and the new defined one.

Parameters

string|\DateTimeZone $timezone

Timezone to which you wish to offset. You can either pass \DateTimeZone object or a valid timezone string. For timezone string formats visit: http://php.net/manual/en/timezones.php

Returns

$this

getDate()

getDate(null|string  $format = null) : string

Get date in full date format.

Parameters

null|string $format

A valid date format.

Returns

string —

Date in full date format like ISO 8691 or RFC 2822.

getYear()

getYear(null|string  $format = null) : string

Get year based on current date.

Parameters

null|string $format

A valid year format.

Returns

string —

Year based on current date.

getMonth()

getMonth(null|string  $format = null) : string

Get month based on current date.

Parameters

null|string $format

A valid month format.

Returns

string —

Month based on current date.

getWeek()

getWeek() : integer

Get week number based on current date.

Returns

integer —

Wek number based on current date.

getDay()

getDay(null|string  $format = null) : string

Get day based on current date.

Parameters

null|string $format

A valid day format.

Returns

string —

Day based on current date.

getTime()

getTime(null|string  $format = null) : string

Return time based on current date.

Parameters

null|string $format

A valid time format.

Returns

string —

Time based on current date.

getHours()

getHours(null|string  $format = null) : string

Get hours based on current date.

Parameters

null|string $format

A valid hour format.

Returns

string —

Hours based on current date.

getMeridiem()

getMeridiem(null|string  $format = null) : string

Get meridiem (am, pm) based on current date.

Parameters

null|string $format

A valid meridiem format.

Returns

string —

Meridiem (am, pm) based on current date.

getMinutes()

getMinutes() : string

Get minutes based on current date.

Returns

string —

Minutes based on current date

getSeconds()

getSeconds() : string

Get seconds based on current date.

Returns

string —

Seconds based on current date.

getTimeAgo()

getTimeAgo(null  $from = null) : string

Calculates the time passed between current date and $form (default: now).

The output is formatted in plain words, like "4 hours ago".

Parameters

null $from

Timestamp from where to calculate the offset. Default is now.

Returns

string —

String describing the passed time. Example "4 hours ago".

getTimestamp()

getTimestamp() : integer

Get UNIX timestamp based on current date.

Returns

integer —

UNIX timestamp based on current date

__toString()

__toString() : mixed

To string implementation.

Returns

mixed

format()

format(string  $format) : string

Return date in the given format.

Parameters

string $format

A valid date format.

Returns

string —

A string containing the date in the given $format.

getObject()

getObject() : $this

Returns an Instance of current Object

Returns

$this

is()

is(  $var) 

Parameters

$var

isNull()

isNull(mixed  $var) : boolean

Checks if given value is null.

Parameters

mixed $var

Value to check

Returns

boolean

isEmpty()

isEmpty(mixed  $var) : boolean

Checks if given value is empty.

Parameters

mixed $var

Value to check

Returns

boolean

isObject()

isObject(mixed  $var) : boolean

Check if given value is an object.

Parameters

mixed $var

Value to check

Returns

boolean

isScalar()

isScalar(mixed  $var) : boolean

Check if given value is a scalar value.

Scalar values are: integer, float, boolean and string

Parameters

mixed $var

Value to check

Returns

boolean

isResource()

isResource(mixed  $var) : boolean

Check if given value is a resource.

Parameters

mixed $var

Value to check

Returns

boolean

isArray()

isArray(  $var) : boolean

Checks if given value is an array.

Parameters

$var

Returns

boolean

isNumber()

isNumber(  $var) : boolean

Checks if value is a number.

Parameters

$var

Returns

boolean

isInteger()

isInteger(  $var) : boolean

Checks if value is an integer.

Parameters

$var

Returns

boolean

isCallable()

isCallable(  $var) : boolean

Checks whenever resource is callable.

Parameters

$var

Returns

boolean

isString()

isString(  $var) : boolean

Checks if $var is type of string.

Parameters

$var

Returns

boolean

isBool()

isBool(  $var) : boolean

Checks if $var is type of boolean.

Parameters

$var

Returns

boolean

isBoolean()

isBoolean(  $var) : boolean

This is an alias function for self::isBool

Parameters

$var

Returns

boolean

isFile()

isFile(  $var) : boolean

Checks if $var is a file.

Parameters

$var

Returns

boolean

isReadable()

isReadable(  $var) : boolean

Checks if $var is readable.

Parameters

$var

Returns

boolean

isDirectory()

isDirectory(  $var) : boolean

Checks if $var is a directory.

Parameters

$var

Returns

boolean

isInstanceOf()

isInstanceOf(mixed  $instance, string  $type) : boolean

Check if $instance is of $type.

Parameters

mixed $instance
string $type

Returns

boolean

isSubClassOf()

isSubClassOf(string|object  $subclass, string  $class) : boolean

Check if $subclass is a subclass of $class.

Parameters

string|object $subclass
string $class

Returns

boolean

isStringObject()

isStringObject(mixed  $instance) : boolean

Check if $instance is a StringObject.

Parameters

mixed $instance

Returns

boolean

isDateTimeObject()

isDateTimeObject(mixed  $instance) : boolean

Check if $instance is a DateTimeObject.

Parameters

mixed $instance

Returns

boolean

isFileObject()

isFileObject(mixed  $instance) : boolean

Check if $instance is a FileObject.

Parameters

mixed $instance

Returns

boolean

isArrayObject()

isArrayObject(mixed  $instance) : boolean

Check if $instance is an ArrayObject.

Parameters

mixed $instance

Returns

boolean

isUrlObject()

isUrlObject(mixed  $instance) : boolean

Check if $instance is a UrlObject.

Parameters

mixed $instance

Returns

boolean

parseDateInterval()

parseDateInterval(  $interval) : \DateInterval

Parameters

$interval

Returns

\DateInterval

getDateObject()

getDateObject() : \DateTime|null

Returns current \DateTime object.

Returns

\DateTime|null

getDateElement()

getDateElement(string  $dateElement, null|string  $format = null) : string

Returns defined $dateElement in defined $format.

Parameters

string $dateElement

Possible values are: date, year, month, day, time, hour, minutes, seconds, meridiem.

null|string $format

For list of possible formats check: http://php.net/manual/en/function.date.php

Returns

string

getFormatFor()

getFormatFor(string  $dateElement) : mixed

Returns format for defined $dateElement.

Parameters

string $dateElement

Possible values are: date, year, month, day, time, hour, minutes, seconds, meridiem.

Returns

mixed

parseDateTimeFormat()

parseDateTimeFormat() 

This function parses the format provided by Config and sets the default formatting for getting date information like day, month, year, etc.

.

createTimezone()

createTimezone(string|null  $timezone = null) : \DateTimeZone

Create a DateTimeZone object for the given $timeZone.

If $timezone is undefined, default timezone is returned. Default timezone is the servers timezone.

Parameters

string|null $timezone

A valid time zone. For list of available timezones visit: http://www.php.net/manual/en/timezones.php

Returns

\DateTimeZone

buildFormatterList()

buildFormatterList() 

Reformats self::$formatters from array to ArrayObject.

validateFormatFor()

validateFormatFor(string  $dateElement, string  $format) : mixed

Checks if $format is a valid format for $dateElement.

Parameters

string $dateElement

Possible values are: date, year, month, day, time, hour, minutes, seconds, meridiem.

string $format

For list of possible formats check: http://php.net/manual/en/function.date.php

Throws

\app\framework\Component\StdLib\StdObject\DateTimeObject\DateTimeObjectException

Returns

mixed