milliseconds

Creates durations from numbers of milliseconds, or converts durations to milliseconds.

Category: Language Fundamentals > Data Types

Syntax

d = milliseconds(x)

Returns a duration array in which each value of x is a number of milliseconds.

x = milliseconds(d)

Returns the number of milliseconds in the duration array d, as a double.

Description

A duration stores a length of time independent of the unit used to show it. milliseconds(1500) is displayed as 1.5 sec because the display picks a convenient unit, but the value is the same. Durations can be added to each other and to datetimes.

Input arguments

x
Numeric array.
d
A duration array.

Output arguments

d
duration array, same size as x.
x
Double array, same size as d.

Example

Milliseconds in and out

d = milliseconds(1500)
milliseconds(minutes(1))
d + seconds(1)
Output
d = duration
   1.5 sec
ans = 60000
ans = duration
   2.5 sec

See also

seconds minutes hours days duration