Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

second

Syntax

s = second(t)
s = second(t,secondType)

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 array
Columns 1 through 2

   26-Feb-2018 19:46:46.500   26-Feb-2018 19:47:01.500

Column 3

   26-Feb-2018 19:47:16.500

s = second(t)
s = 1×3

   46.5007    1.5007   16.5007

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

See Also

| | | |

Introduced in R2014b

Was this topic helpful?