function GPBUtil::formatTimestamp
2 calls to GPBUtil::formatTimestamp()
- Message::jsonByteSize in vendor/
google/ protobuf/ src/ Google/ Protobuf/ Internal/ Message.php - @ignore
- Message::serializeToJsonStream in vendor/
google/ protobuf/ src/ Google/ Protobuf/ Internal/ Message.php - @ignore
File
-
vendor/
google/ protobuf/ src/ Google/ Protobuf/ Internal/ GPBUtil.php, line 488
Class
Namespace
Google\Protobuf\InternalCode
public static function formatTimestamp($value) {
if (bccomp($value->getSeconds(), "253402300800") != -1) {
throw new GPBDecodeException("Duration number too large.");
}
if (bccomp($value->getSeconds(), "-62135596801") != 1) {
throw new GPBDecodeException("Duration number too small.");
}
$nanoseconds = static::getNanosecondsForTimestamp($value->getNanos());
if (!empty($nanoseconds)) {
$nanoseconds = "." . $nanoseconds;
}
$date = new \DateTime('@' . $value->getSeconds(), new \DateTimeZone("UTC"));
return $date->format("Y-m-d\\TH:i:s" . $nanoseconds . "\\Z");
}