In general case you need to compare DateTimes
with the same Kind
:
if (date1.ToUniversalTime() < date2.ToUniversalTime())
Console.WriteLine("date1 is earlier than date2");
Explanation from MSDN about DateTime.Compare
(This is also relevant for operators like >
, <
, ==
and etc.):
To determine the relationship of t1 to t2, the Compare method compares the Ticks property of t1 and t2 but ignores their Kind property. Before comparing DateTime objects, ensure that the objects represent times in the same time zone.
Thus, a simple comparison may give an unexpected result when dealing with DateTimes
that are represented in different timezones.