Reference documentation and code samples for the Google Cloud PHP shared dependency, providing functionality useful to all components. Client class Duration.
Represents a Duration type.
Example:
use Google\Cloud\Core\Duration;
$seconds = 100;
$nanoSeconds = 1000;
$duration = new Duration($seconds, $nanoSeconds);
// Duration objects can be cast to json-encoded strings.
echo (string) $duration;
Namespace
Google \ Cloud \ Core
Methods
__construct
Parameters
Name
Description
seconds
int
The number of seconds in the duration.
nanos
int
[optional] The number of nanoseconds in the duration.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Google Cloud PHP shared dependency, providing functionality useful to all components. Client - Class Duration (1.64.2)\n\nVersion latestkeyboard_arrow_down\n\n- [1.64.2 (latest)](/php/docs/reference/cloud-core/latest/Duration)\n- [1.64.1](/php/docs/reference/cloud-core/1.64.1/Duration)\n- [1.63.0](/php/docs/reference/cloud-core/1.63.0/Duration)\n- [1.62.3](/php/docs/reference/cloud-core/1.62.3/Duration)\n- [1.61.0](/php/docs/reference/cloud-core/1.61.0/Duration)\n- [1.60.1](/php/docs/reference/cloud-core/1.60.1/Duration)\n- [1.59.1](/php/docs/reference/cloud-core/1.59.1/Duration)\n- [1.58.2](/php/docs/reference/cloud-core/1.58.2/Duration)\n- [1.53.0](/php/docs/reference/cloud-core/1.53.0/Duration)\n- [1.52.11](/php/docs/reference/cloud-core/1.52.11/Duration)\n- [1.51.2](/php/docs/reference/cloud-core/1.51.2/Duration)\n- [1.50.0](/php/docs/reference/cloud-core/1.50.0/Duration)\n- [1.49.3](/php/docs/reference/cloud-core/1.49.3/Duration)\n- [1.48.1](/php/docs/reference/cloud-core/1.48.1/Duration) \nReference documentation and code samples for the Google Cloud PHP shared dependency, providing functionality useful to all components. Client class Duration.\n\nRepresents a Duration type.\n\nExample: \n\n use Google\\Cloud\\Core\\Duration;\n\n $seconds = 100;\n $nanoSeconds = 1000;\n $duration = new Duration($seconds, $nanoSeconds);\n\n // Duration objects can be cast to json-encoded strings.\n echo (string) $duration;\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Core\n\nMethods\n-------\n\n### __construct\n\n### get\n\nGet the duration\n\nExample: \n\n $res = $duration-\u003eget();\n\n### formatAsString\n\nFormat the value as a string.\n\nExample: \n\n echo $duration-\u003eformatAsString();\n\n### __toString\n\nFormat the value as a string.\n\nConstants\n---------\n\n### TYPE\n\n Value: 'DURATION'"]]