How many hours/minutes/seconds/etc have elapsed

	TimeSpan TimeElapsed = DateTime.Now - DateTime1;
	int MinutesElapsed = (int)TimeElapsed.TotalMinutes;     //Note that TimeElapsed.Minutes gives you minutes as 0-59, not total minutes

Add or subtract a TimeSpan from a DateTime

Don’t use timespan, just use AddHours etc:

	MyDateTime = MyDateTime.AddHours(2);
	MyDateTime = MyDateTime.AddHours(-2);
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published.