Cloud Spanner Client - Class Date (1.91.0)

Reference documentation and code samples for the Cloud Spanner Client class Date.

Represents a value with a data type of Date.

Example:

use Google\Cloud\Spanner\SpannerClient;

$spanner = new SpannerClient();

$date = $spanner->date(new \DateTimeImmutable('1995-02-04'));
// Date objects can be cast to strings for easy display.
echo (string) $date;

Namespace

Google \ Cloud \ Spanner

Methods

__construct

Parameter
Name Description
value DateTimeInterface

The date value.

get

Get the underlying \DateTimeInterface implementation.

Example:

$dateTime = $date->get();
Returns
Type Description
DateTimeInterface

type

Get the type.

Example:

echo $date->type();
Returns
Type Description
int

formatAsString

Format the value as a string.

Example:

echo $date->formatAsString();
Returns
Type Description
string

__toString

Format the value as a string.

Returns
Type Description
string

static::createFromValues

Create a Date from integer or string values.

Example:

$date = Date::createFromValues(1995, 02, 04);
Parameters
Name Description
year int|string

The year.

month int|string

The month (as a number).

day int|string

The day of the month.

Returns
Type Description
Date

Constants

FORMAT

Value: 'Y-m-d'