Date comparison – How to check if 20 minutes have passed?

  1. You should convert your start time to a UTC time, say ‘start’.

  2. You can now compare your start time to the current UTC time using:

    DateTime.UtcNow > start.AddMinutes(20)

This approach means that you will get the correct answer around daylight savings time changes.

By adding time to the start time instead of subtracting and comparing the total time on a TimeSpan you have a more readable syntax AND you can handle more date difference cases, e.g. 1 month from the start, 2 weeks from the start, …

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)