WooCommerce Code Reference

DateTime
in package

Custom scalar for ISO 8601 date/time values.

Table of Contents

parse()  : DateTimeImmutable
Parse a value received from a client (variable or literal).
serialize()  : string
Serialize a PHP value to the scalar's transport format.

Methods

parse()

Parse a value received from a client (variable or literal).

public static parse(string $value) : DateTimeImmutable
Parameters
$value : string

The raw string value from the client.

Tags
throws
InvalidArgumentException

When the value cannot be parsed as an ISO 8601 date/time string.

Return values
DateTimeImmutable

serialize()

Serialize a PHP value to the scalar's transport format.

public static serialize(mixed $value) : string
Parameters
$value : mixed

The value to serialize.

Return values
string