Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

duration()

Returns an object representing a length of time.

Signature

duration (number num, String unit)

Parameters

num
Type: number
The length of time in a given unit.
unit
Type: String
A datetime unit. The default is 'milliseconds'. The options are 'years, 'months', 'weeks', 'days', 'hour', 'minutes', 'seconds', 'milliseconds'.

Returns

Type: Object
A duration object.

Sample Code

1var dur = $A.localizationService.duration(2, 'days');