What was the date 180 days ago?

Viewed 14637

How would I get the date 180 days ago using C#?

5 Answers
DateTime oneEightyAgo = DateTime.Today.AddDays(-180);

EDIT:

DateTime day180 = Date.Now.AddDays(-180);

It's important to put it into a separate variable otherwise the value will be lost.

DateTime oneEightyAgo = DateTime.Now.ToUniversalTime().AddDays(-180); 

Its best to record UTC...

Related