Skip to content

DateTime

DateTime property.

This object represents DATE-TIME values, as defined here:

http://tools.ietf.org/html/rfc5545#section-3.3.4

This particular object has a bit of hackish magic that it may also in some cases represent a DATE value. This is because it's a common usecase to be able to change a DATE-TIME into a DATE.

Properties

delimiter

In case this is a multi-value property. This string will be used as a delimiter.

public string|null $delimiter

Methods

setParts

Sets a multi-valued property.

public setParts(array $parts): mixed

You may also specify DateTime objects here.

Parameters:

Parameter Type Description
$parts array

setValue

Updates the current value.

public setValue(string|array|\DateTimeInterface $value): mixed

This may be either a single, or multiple strings in an array.

Instead of strings, you may also use DateTime here.

Parameters:

Parameter Type Description
$value string|array|\DateTimeInterface

setRawMimeDirValue

Sets a raw value coming from a mimedir (iCalendar/vCard) file.

public setRawMimeDirValue(string $val): mixed

This has been 'unfolded', so only 1 line will be passed. Unescaping is not yet done, but parameters are not included.

Parameters:

Parameter Type Description
$val string

getRawMimeDirValue

Returns a raw mime-dir representation of the value.

public getRawMimeDirValue(): string

hasTime

Returns true if this is a DATE-TIME value, false if it's a DATE.

public hasTime(): bool

isFloating

Returns true if this is a floating DATE or DATE-TIME.

public isFloating(): mixed

Note that DATE is always floating.


getDateTime

Returns a date-time value.

public getDateTime(\DateTimeZone $timeZone = null): \DateTimeImmutable

Note that if this property contained more than 1 date-time, only the first will be returned. To get an array with multiple values, call getDateTimes.

If no timezone information is known, because it's either an all-day property or floating time, we will use the DateTimeZone argument to figure out the exact date.

Parameters:

Parameter Type Description
$timeZone \DateTimeZone

getDateTimes

Returns multiple date-time values.

public getDateTimes(\DateTimeZone $timeZone = null): \DateTimeImmutable[]

If no timezone information is known, because it's either an all-day property or floating time, we will use the DateTimeZone argument to figure out the exact date.

Parameters:

Parameter Type Description
$timeZone \DateTimeZone

setDateTime

Sets the property as a DateTime object.

public setDateTime(\DateTimeInterface $dt, mixed $isFloating = false): mixed

Parameters:

Parameter Type Description
$dt \DateTimeInterface
$isFloating mixed

setDateTimes

Sets the property as multiple date-time objects.

public setDateTimes(\DateTimeInterface[] $dt, mixed $isFloating = false): mixed

The first value will be used as a reference for the timezones, and all the other values will be adjusted for that timezone

Parameters:

Parameter Type Description
$dt \DateTimeInterface[]
$isFloating mixed

getValueType

Returns the type of value.

public getValueType(): string

This corresponds to the VALUE= parameter. Every property also has a 'default' valueType.


getJsonValue

Returns the value, in the format it should be encoded for JSON.

public getJsonValue(): array

This method must always return an array.


setJsonValue

Sets the json value, as it would appear in a jCard or jCal object.

public setJsonValue(array $value): mixed

The value must always be an array.

Parameters:

Parameter Type Description
$value array

offsetSet

We need to intercept offsetSet, because it may be used to alter the VALUE from DATE-TIME to DATE or vice-versa.

public offsetSet(string $name, mixed $value): mixed

Parameters:

Parameter Type Description
$name string
$value mixed

validate

Validates the node for correctness.

public validate(int $options): array

The following options are supported: Node::REPAIR - May attempt to automatically repair the problem.

This method returns an array with detected problems. Every element has the following properties:

  • level - problem level.
  • message - A human-readable string describing the issue.
  • node - A reference to the problematic node.

The level means: 1 - The issue was repaired (only happens if REPAIR was turned on) 2 - An inconsequential issue 3 - A severe issue.

Parameters:

Parameter Type Description
$options int

Inherited methods

serialize

Turns the object back into a serialized blob.

public serialize(): string

jsonSerialize

This method returns an array, with the representation as it should be encoded in JSON. This is used to create jCard or jCal documents.

public jsonSerialize(): array

xmlSerialize

This method serializes the data into XML. This is used to create xCard or xCal documents.

public xmlSerialize(\Sabre\Xml\Writer $writer): void

Parameters:

Parameter Type Description
$writer \Sabre\Xml\Writer XML writer

destroy

Call this method on a document if you're done using it.

public destroy(): mixed

It's intended to remove all circular references, so PHP can easily clean it up.


getIterator

Returns the iterator for this object.

public getIterator(): \Sabre\VObject\ElementList

setIterator

Sets the overridden iterator.

public setIterator(\Sabre\VObject\ElementList $iterator): mixed

Note that this is not actually part of the iterator interface

Parameters:

Parameter Type Description
$iterator \Sabre\VObject\ElementList

validate

Validates the node for correctness.

public validate(int $options): array

The following options are supported: - Node::REPAIR - If something is broken, and automatic repair may be attempted.

An array is returned with warnings.

Every item in the array has the following properties: * level - (number between 1 and 3 with severity information) * message - (human readable message) * node - (reference to the offending node)

Parameters:

Parameter Type Description
$options int

count

Returns the number of elements.

public count(): int

offsetExists

Checks if an array element exists.

public offsetExists(mixed $name): bool

Parameters:

Parameter Type Description
$name mixed

offsetGet

Returns a parameter.

public offsetGet(string $name): \Sabre\VObject\Node

If the parameter does not exist, null is returned.

Parameters:

Parameter Type Description
$name string

offsetSet

Creates a new parameter.

public offsetSet(string $name, mixed $value): mixed

Parameters:

Parameter Type Description
$name string
$value mixed

offsetUnset

Removes one or more parameters with the specified name.

public offsetUnset(string $name): mixed

Parameters:

Parameter Type Description
$name string

__construct

Creates the generic property.

public __construct(\Sabre\VObject\Component $root, string $name, string|array|null $value = null, array $parameters = [], string $group = null, int $lineIndex = null, string $lineString = null): mixed

Parameters must be specified in key=>value syntax.

Parameters:

Parameter Type Description
$root \Sabre\VObject\Component The root document
$name string
$value string|array|null
$parameters array List of parameters
$group string The vcard property group
$lineIndex int
$lineString string

setValue

Updates the current value.

public setValue(string|array $value): mixed

This may be either a single, or multiple strings in an array.

Parameters:

Parameter Type Description
$value string|array

getValue

Returns the current value.

public getValue(): string

This method will always return a singular value. If this was a multi-value object, some decision will be made first on how to represent it as a string.

To get the correct multi-value version, use getParts.


setParts

Sets a multi-valued property.

public setParts(array $parts): mixed

Parameters:

Parameter Type Description
$parts array

getParts

Returns a multi-valued property.

public getParts(): array

This method always returns an array, if there was only a single value, it will still be wrapped in an array.


add

Adds a new parameter.

public add(string $name, string|array|null $value = null): mixed

If a parameter with same name already existed, the values will be combined. If nameless parameter is added, we try to guess its name.

Parameters:

Parameter Type Description
$name string
$value string|array|null

parameters

Returns an iterable list of children.

public parameters(): array

getValueType

Returns the type of value.

public getValueType(): string

This corresponds to the VALUE= parameter. Every property also has a 'default' valueType.

  • This method is abstract.

setRawMimeDirValue

Sets a raw value coming from a mimedir (iCalendar/vCard) file.

public setRawMimeDirValue(string $val): mixed

This has been 'unfolded', so only 1 line will be passed. Unescaping is not yet done, but parameters are not included.

  • This method is abstract.

Parameters:

Parameter Type Description
$val string

getRawMimeDirValue

Returns a raw mime-dir representation of the value.

public getRawMimeDirValue(): string
  • This method is abstract.

getJsonValue

Returns the value, in the format it should be encoded for JSON.

public getJsonValue(): array

This method must always return an array.


setJsonValue

Sets the JSON value, as it would appear in a jCard or jCal object.

public setJsonValue(array $value): mixed

The value must always be an array.

Parameters:

Parameter Type Description
$value array

setXmlValue

Hydrate data from a XML subtree, as it would appear in a xCard or xCal object.

public setXmlValue(array $value): mixed

Parameters:

Parameter Type Description
$value array

xmlSerializeValue

This method serializes only the value of a property. This is used to create xCard or xCal documents.

protected xmlSerializeValue(\Sabre\Xml\Writer $writer): mixed

Parameters:

Parameter Type Description
$writer \Sabre\Xml\Writer XML writer

__toString

Called when this object is being cast to a string.

public __toString(): string

If the property only had a single value, you will get just that. In the case the property had multiple values, the contents will be escaped and combined with ,.


__clone

This method is automatically called when the object is cloned.

public __clone(): mixed

Specifically, this will ensure all child elements are also cloned.



Automatically generated on 2025-03-18