google.protobuf.Timestamp
*/
class Timestamp extends \Google\Protobuf\Internal\Message
{
/**
* Represents seconds of UTC time since Unix epoch
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
* 9999-12-31T23:59:59Z inclusive.
*
* Generated from protobuf field int64 seconds = 1;
*/
private $seconds = 0;
/**
* Non-negative fractions of a second at nanosecond resolution. Negative
* second values with fractions must still have non-negative nanos values
* that count forward in time. Must be from 0 to 999,999,999
* inclusive.
*
* Generated from protobuf field int32 nanos = 2;
*/
private $nanos = 0;
public function __construct() {
\GPBMetadata\Google\Protobuf\Timestamp::initOnce();
parent::__construct();
}
/**
* Represents seconds of UTC time since Unix epoch
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
* 9999-12-31T23:59:59Z inclusive.
*
* Generated from protobuf field int64 seconds = 1;
* @return int|string
*/
public function getSeconds()
{
return $this->seconds;
}
/**
* Represents seconds of UTC time since Unix epoch
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
* 9999-12-31T23:59:59Z inclusive.
*
* Generated from protobuf field int64 seconds = 1;
* @param int|string $var
* @return $this
*/
public function setSeconds($var)
{
GPBUtil::checkInt64($var);
$this->seconds = $var;
return $this;
}
/**
* Non-negative fractions of a second at nanosecond resolution. Negative
* second values with fractions must still have non-negative nanos values
* that count forward in time. Must be from 0 to 999,999,999
* inclusive.
*
* Generated from protobuf field int32 nanos = 2;
* @return int
*/
public function getNanos()
{
return $this->nanos;
}
/**
* Non-negative fractions of a second at nanosecond resolution. Negative
* second values with fractions must still have non-negative nanos values
* that count forward in time. Must be from 0 to 999,999,999
* inclusive.
*
* Generated from protobuf field int32 nanos = 2;
* @param int $var
* @return $this
*/
public function setNanos($var)
{
GPBUtil::checkInt32($var);
$this->nanos = $var;
return $this;
}
/**
* Converts PHP DateTime to Timestamp.
*
* @param DateTime $datetime
*/
public function fromDateTime($datetime)
{
if (get_class($datetime) !== \DateTime::class) {
trigger_error("Given parameter is not a DateTime.",
E_USER_ERROR);
}
$this->seconds = $datetime->format('U');
$this->nanos = 0;
}
/**
* Converts Timestamp to PHP DateTime. Nano second is ignored.
*
* @return DateTime $datetime
*/
public function toDateTime()
{
return \DateTime::createFromFormat('U', $this->seconds);
}
}