Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan 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 = 1×3 datetime array
   24-Feb-2017 12:38:45.568   24-Feb-2017 12:39:00.568   24-Feb-2017 12:39:15.568

s = second(t)
s = 

   45.5690    0.5690   15.5690

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

Was this topic helpful?