The comparison looks fine and behaves as expected on my machine.
The interpretation of the date could be the problem. It parses the date based on the date settings of your computer. On my computer (Dutch, nl-NL) it throws an exception unless I either:
- Change the format:
DateTime time = DateTime.Parse("20-06-2018 04:38:26");
- Set the thread culture to en-US:
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");