second

Seconds component of a datetime.

Category: Language Fundamentals > Data Types

Syntax

s = second(t)

Returns the seconds (0 up to but not including 60) of each element of t.

Description

second extracts one field of a date and time, like hour and minute do. It is not the same as seconds, which builds a duration from a number.

Input arguments

t
Datetime array.

Output arguments

s
Double array of the same size as t; fractions of a second are kept.

Example

second(datetime(2024, 1, 1, 10, 20, 30.5))
Output
ans = 30.5000

See also

minute hour seconds datetime day