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

   17-Aug-2020 15:44:10.644   17-Aug-2020 15:44:25.644

Column 3

   17-Aug-2020 15:44:40.644

s = second(t)
s = 1×3

   10.6446   25.6446   40.6446

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