Freigeben über


Calendar.AddSeconds Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Returns a DateTime that is the specified number of seconds away from the specified DateTime.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Overridable Function AddSeconds ( _
    time As DateTime, _
    seconds As Integer _
) As DateTime
public virtual DateTime AddSeconds(
    DateTime time,
    int seconds
)

Parameters

Return Value

Type: System.DateTime
The DateTime that results from adding the specified number of seconds to the specified DateTime.

Exceptions

Exception Condition
ArgumentException

The resulting DateTime is outside the supported range of this calendar.

ArgumentOutOfRangeException

seconds is outside the supported range of the DateTime return value.

Remarks

The seconds value is added to the specified DateTime. If seconds is negative, the resulting DateTime is earlier than the specified DateTime.

The day part of the resulting DateTime is affected if the resulting time is outside the day of the specified DateTime. The month part of the resulting DateTime is affected if the resulting day is outside the month of the specified DateTime. The year part of the resulting DateTime is affected if the resulting month is outside the year of the specified DateTime. The era part of the resulting DateTime is affected if the resulting year is outside the era of the specified DateTime.

Examples

The following code example demonstrates the members of the Calendar class.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.