second

Description

example

s = second(t) returns the second values, including a fractional part, for the datetime values in t. The s output is a double array the same size as t and contains values from 0 to less than 60.

For datetime values whose time zone is UTCLeapSeconds, the s output can contain a value between 60 and 61 for times that fall during a leap second occurrence.

s = second(t,secondType) returns the type of second number specified by secondType.

The second function returns the second numbers of datetime values. To assign second values to datetime array t, use t.Second and modify the Second property.

Examples

collapse all

t1 = datetime('now','Format','dd-MMM-yyyy HH:mm:ss.SSS');
t = t1 + seconds(30:15:60)
t = 1x3 datetime
Columns 1 through 2

   29-Jan-2020 11:31:15.053   29-Jan-2020 11:31:30.053

Column 3

   29-Jan-2020 11:31:45.053

s = second(t)
s = 1×3

   15.0539   30.0539   45.0539

Input Arguments

collapse all

Input date and time, specified as a datetime array.

Type of second values, specified as either 'secondofminute' or 'secondofday'.

  • If secondType is 'secondofminute', then second returns the second of the minute.

  • If secondType is 'secondofday', then second returns the second of the day, which (except for leap seconds) is in the range [0, 86400).

Extended Capabilities

Introduced in R2014b