Duration class with an interface similar to the tc39 Temporal proposal. Since it's not fully finalized, and polyfills have inconsistent compatibility, for now this shim class will be used to set durations in Pub/Sub.
This class will remain here for at least the next major version, eventually to be replaced by the tc39 Temporal built-in.
[[["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,["# Class Duration (4.8.0)\n\nVersion latestkeyboard_arrow_down\n\n- [4.8.0 (latest)](/nodejs/docs/reference/pubsub/latest/pubsub/duration)\n- [4.4.0](/nodejs/docs/reference/pubsub/4.4.0/pubsub/duration)\n- [4.3.3](/nodejs/docs/reference/pubsub/4.3.3/pubsub/duration)\n- [4.1.1](/nodejs/docs/reference/pubsub/4.1.1/pubsub/duration)\n- [4.0.7](/nodejs/docs/reference/pubsub/4.0.7/pubsub/duration)\n- [3.7.5](/nodejs/docs/reference/pubsub/3.7.5/pubsub/duration)\n- [3.2.1](/nodejs/docs/reference/pubsub/3.2.1/pubsub/duration)\n- [3.1.1](/nodejs/docs/reference/pubsub/3.1.1/pubsub/duration)\n- [3.0.3](/nodejs/docs/reference/pubsub/3.0.3/pubsub/duration)\n- [2.18.3](/nodejs/docs/reference/pubsub/2.18.3/pubsub/duration)\n- [2.17.0](/nodejs/docs/reference/pubsub/2.17.0/pubsub/duration)\n- [2.16.6](/nodejs/docs/reference/pubsub/2.16.6/pubsub/duration)\n- [2.13.0](/nodejs/docs/reference/pubsub/2.13.0/pubsub/duration) \nDuration class with an interface similar to the tc39 Temporal proposal. Since it's not fully finalized, and polyfills have inconsistent compatibility, for now this shim class will be used to set durations in Pub/Sub.\n\nThis class will remain here for at least the next major version, eventually to be replaced by the tc39 Temporal built-in.\n\n\u003chttps://tc39.es/proposal-temporal/docs/duration.html\u003e\n\nPackage\n-------\n\n[@google-cloud/pubsub](../overview.html)\n\nMethods\n-------\n\n### from(durationLike)\n\n static from(durationLike: DurationLike): Duration;\n\nCreates a Duration from a DurationLike, which is an object containing zero or more of the following: hours, seconds, minutes, millis.\n\n### totalOf(totalOf)\n\n totalOf(totalOf: TotalOfUnit): number;\n\nCalculates the total number of units of type 'totalOf' that would fit inside this duration."]]