Documentation

DateTime extends Message
in package

Represents civil time (or occasionally physical time).

This type can represent a civil time in one of a few possible ways:

  • When utc_offset is set and time_zone is unset: a civil time on a calendar day with a particular offset from UTC.
  • When time_zone is set and utc_offset is unset: a civil time on a calendar day in a particular time zone.
  • When neither time_zone nor utc_offset is set: a civil time on a calendar day in local time. The date is relative to the Proleptic Gregorian Calendar. If year is 0, the DateTime is considered not to have a specific year. month and day must have valid, non-zero values. This type may also be used to represent a physical time if all the date and time fields are set and either case of the time_offset oneof is set. Consider using Timestamp message for physical time instead. If your use case also would like to store the user's timezone, that can be done in another field. This type is more flexible than some applications may want. Make sure to document and validate your application's limitations.

Generated from protobuf message google.type.DateTime

Table of Contents

Properties

$day  : mixed
Required. Day of month. Must be from 1 to 31 and valid for the year and month.
$hours  : mixed
Required. Hours of day in 24 hour format. Should be from 0 to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.
$minutes  : mixed
Required. Minutes of hour of day. Must be from 0 to 59.
$month  : mixed
Required. Month of year. Must be from 1 to 12.
$nanos  : mixed
Required. Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
$seconds  : mixed
Required. Seconds of minutes of the time. Must normally be from 0 to 59. An API may allow the value 60 if it allows leap-seconds.
$time_offset  : mixed
$year  : mixed
Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a datetime without a year.

Methods

__construct()  : mixed
Constructor.
getDay()  : int
Required. Day of month. Must be from 1 to 31 and valid for the year and month.
getHours()  : int
Required. Hours of day in 24 hour format. Should be from 0 to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.
getMinutes()  : int
Required. Minutes of hour of day. Must be from 0 to 59.
getMonth()  : int
Required. Month of year. Must be from 1 to 12.
getNanos()  : int
Required. Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
getSeconds()  : int
Required. Seconds of minutes of the time. Must normally be from 0 to 59. An API may allow the value 60 if it allows leap-seconds.
getTimeOffset()  : string
getTimeZone()  : TimeZone|null
Time zone.
getUtcOffset()  : Duration|null
UTC offset. Must be whole seconds, between -18 hours and +18 hours.
getYear()  : int
Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a datetime without a year.
hasTimeZone()  : mixed
hasUtcOffset()  : mixed
setDay()  : $this
Required. Day of month. Must be from 1 to 31 and valid for the year and month.
setHours()  : $this
Required. Hours of day in 24 hour format. Should be from 0 to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.
setMinutes()  : $this
Required. Minutes of hour of day. Must be from 0 to 59.
setMonth()  : $this
Required. Month of year. Must be from 1 to 12.
setNanos()  : $this
Required. Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
setSeconds()  : $this
Required. Seconds of minutes of the time. Must normally be from 0 to 59. An API may allow the value 60 if it allows leap-seconds.
setTimeZone()  : $this
Time zone.
setUtcOffset()  : $this
UTC offset. Must be whole seconds, between -18 hours and +18 hours.
setYear()  : $this
Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a datetime without a year.

Properties

$day

Required. Day of month. Must be from 1 to 31 and valid for the year and month.

protected mixed $day = 0

Generated from protobuf field int32 day = 3 [json_name = "day"];

$hours

Required. Hours of day in 24 hour format. Should be from 0 to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.

protected mixed $hours = 0

Generated from protobuf field int32 hours = 4 [json_name = "hours"];

$minutes

Required. Minutes of hour of day. Must be from 0 to 59.

protected mixed $minutes = 0

Generated from protobuf field int32 minutes = 5 [json_name = "minutes"];

$month

Required. Month of year. Must be from 1 to 12.

protected mixed $month = 0

Generated from protobuf field int32 month = 2 [json_name = "month"];

$nanos

Required. Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.

protected mixed $nanos = 0

Generated from protobuf field int32 nanos = 7 [json_name = "nanos"];

$seconds

Required. Seconds of minutes of the time. Must normally be from 0 to 59. An API may allow the value 60 if it allows leap-seconds.

protected mixed $seconds = 0

Generated from protobuf field int32 seconds = 6 [json_name = "seconds"];

$time_offset

protected mixed $time_offset

$year

Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a datetime without a year.

protected mixed $year = 0

Generated from protobuf field int32 year = 1 [json_name = "year"];

Methods

__construct()

Constructor.

public __construct([array<string|int, mixed> $data = NULL ]) : mixed
Parameters
$data : array<string|int, mixed> = NULL

{ Optional. Data for populating the Message object.

@type int $year
      Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a
      datetime without a year.
@type int $month
      Required. Month of year. Must be from 1 to 12.
@type int $day
      Required. Day of month. Must be from 1 to 31 and valid for the year and
      month.
@type int $hours
      Required. Hours of day in 24 hour format. Should be from 0 to 23. An API
      may choose to allow the value "24:00:00" for scenarios like business
      closing time.
@type int $minutes
      Required. Minutes of hour of day. Must be from 0 to 59.
@type int $seconds
      Required. Seconds of minutes of the time. Must normally be from 0 to 59. An
      API may allow the value 60 if it allows leap-seconds.
@type int $nanos
      Required. Fractions of seconds in nanoseconds. Must be from 0 to
      999,999,999.
@type \Google\Protobuf\Duration $utc_offset
      UTC offset. Must be whole seconds, between -18 hours and +18 hours.
      For example, a UTC offset of -4:00 would be represented as
      { seconds: -14400 }.
@type \Google\Type\TimeZone $time_zone
      Time zone.

}

getDay()

Required. Day of month. Must be from 1 to 31 and valid for the year and month.

public getDay() : int

Generated from protobuf field int32 day = 3 [json_name = "day"];

Return values
int

getHours()

Required. Hours of day in 24 hour format. Should be from 0 to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.

public getHours() : int

Generated from protobuf field int32 hours = 4 [json_name = "hours"];

Return values
int

getMinutes()

Required. Minutes of hour of day. Must be from 0 to 59.

public getMinutes() : int

Generated from protobuf field int32 minutes = 5 [json_name = "minutes"];

Return values
int

getMonth()

Required. Month of year. Must be from 1 to 12.

public getMonth() : int

Generated from protobuf field int32 month = 2 [json_name = "month"];

Return values
int

getNanos()

Required. Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.

public getNanos() : int

Generated from protobuf field int32 nanos = 7 [json_name = "nanos"];

Return values
int

getSeconds()

Required. Seconds of minutes of the time. Must normally be from 0 to 59. An API may allow the value 60 if it allows leap-seconds.

public getSeconds() : int

Generated from protobuf field int32 seconds = 6 [json_name = "seconds"];

Return values
int

getTimeOffset()

public getTimeOffset() : string
Return values
string

getTimeZone()

Time zone.

public getTimeZone() : TimeZone|null

Generated from protobuf field .google.type.TimeZone time_zone = 9 [json_name = "timeZone"];

Return values
TimeZone|null

getUtcOffset()

UTC offset. Must be whole seconds, between -18 hours and +18 hours.

public getUtcOffset() : Duration|null

For example, a UTC offset of -4:00 would be represented as { seconds: -14400 }.

Generated from protobuf field .google.protobuf.Duration utc_offset = 8 [json_name = "utcOffset"];

Return values
Duration|null

getYear()

Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a datetime without a year.

public getYear() : int

Generated from protobuf field int32 year = 1 [json_name = "year"];

Return values
int

hasTimeZone()

public hasTimeZone() : mixed

hasUtcOffset()

public hasUtcOffset() : mixed

setDay()

Required. Day of month. Must be from 1 to 31 and valid for the year and month.

public setDay(int $var) : $this

Generated from protobuf field int32 day = 3 [json_name = "day"];

Parameters
$var : int
Return values
$this

setHours()

Required. Hours of day in 24 hour format. Should be from 0 to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.

public setHours(int $var) : $this

Generated from protobuf field int32 hours = 4 [json_name = "hours"];

Parameters
$var : int
Return values
$this

setMinutes()

Required. Minutes of hour of day. Must be from 0 to 59.

public setMinutes(int $var) : $this

Generated from protobuf field int32 minutes = 5 [json_name = "minutes"];

Parameters
$var : int
Return values
$this

setMonth()

Required. Month of year. Must be from 1 to 12.

public setMonth(int $var) : $this

Generated from protobuf field int32 month = 2 [json_name = "month"];

Parameters
$var : int
Return values
$this

setNanos()

Required. Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.

public setNanos(int $var) : $this

Generated from protobuf field int32 nanos = 7 [json_name = "nanos"];

Parameters
$var : int
Return values
$this

setSeconds()

Required. Seconds of minutes of the time. Must normally be from 0 to 59. An API may allow the value 60 if it allows leap-seconds.

public setSeconds(int $var) : $this

Generated from protobuf field int32 seconds = 6 [json_name = "seconds"];

Parameters
$var : int
Return values
$this

setTimeZone()

Time zone.

public setTimeZone(TimeZone $var) : $this

Generated from protobuf field .google.type.TimeZone time_zone = 9 [json_name = "timeZone"];

Parameters
$var : TimeZone
Return values
$this

setUtcOffset()

UTC offset. Must be whole seconds, between -18 hours and +18 hours.

public setUtcOffset(Duration $var) : $this

For example, a UTC offset of -4:00 would be represented as { seconds: -14400 }.

Generated from protobuf field .google.protobuf.Duration utc_offset = 8 [json_name = "utcOffset"];

Parameters
$var : Duration
Return values
$this

setYear()

Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a datetime without a year.

public setYear(int $var) : $this

Generated from protobuf field int32 year = 1 [json_name = "year"];

Parameters
$var : int
Return values
$this

        
On this page

Search results