-3

I want to know how I Should compare dateTime.now with my custom time, for example I want to know if the current time is in the middle of 09:00 and 18:00.

It's Simple, but I not getting how should I Compare this times.

Thanks a lot

Mostafiz
  • 7,243
  • 3
  • 28
  • 42
  • 1
    Company I work for provides search engine to look for C# answers (in addition to other searches) - try before asking next time - i.e. https://www.bing.com/search?q=c%23+compare+datetime – Alexei Levenkov Aug 23 '16 at 16:40

1 Answers1

0

You can do by this

DateTime now = DateTime.Now;
DateTime d1 = DateTime.ParseExact(now.ToString("dd/MM/yyyy")+ " 09:00", "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

if (now > d1)
{
    Console.WriteLine("Greater");
}
Mostafiz
  • 7,243
  • 3
  • 28
  • 42