🚀 Welcome to MDriven Learn –  Don’t miss the latest Release Notes.
OCLOperators AddMilliseconds

.AddMilliseconds returns a new DateTime moved forward by a number of milliseconds. Use a negative number to move backward and get an earlier time.

Syntax

aDateTime.AddMilliseconds(numberOfMilliseconds)

Returns

DateTime

Examples

Forward 1500 milliseconds:

DateTime.Parse('2026-11-23 14:30:00').AddMilliseconds(1500).ToString('yyyy-MM-dd HH:mm:ss.fff')

Result: 2026-11-23 14:30:01.500

Back 1500 milliseconds (negative value):

DateTime.Parse('2026-11-23 14:30:00').AddMilliseconds(-1500).ToString('yyyy-MM-dd HH:mm:ss.fff')

Result: 2026-11-23 14:29:58.500

Notes

  • The default .ToString output hides milliseconds. Use a format such as .ToString('yyyy-MM-dd HH:mm:ss.fff') to see them.

See also