Why DateTime.AddHours doesn’t seem to work?

Dates are immutable objects, i.e. they cannot be modified after creation. DateTime.AddHours returns a new DateTime instance which is shifted backwards by 4 hours but “date” will not be modified.

Use:

DateTime newDate = date.AddHours(-4);

Leave a Comment