AddSeconds Method

Calendar.AddSeconds Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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

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

public virtual DateTime AddSeconds(
	DateTime time,
	int seconds
)

Parameters

time
Type: System.DateTime
The DateTime to which to add seconds.
seconds
Type: System.Int32
The number of seconds to add.

Return Value

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

ExceptionCondition
ArgumentException

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

ArgumentOutOfRangeException

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

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.

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

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft