0

I need to give the boolean flag to the user that the system time falls under a given span from the user.

User enter time in this format:

           "startDate": "2013-08-13",
            "startTime": "20:50:32",
            "endDate": "2013-08-13",
            "endTime": "23:50:32",

System time - 4/9/2019 9:41:35 AM

How I can check this system time is under the specified range? c#

I am tried below code

            DateTime startDateTime = DateTime.Parse(startDate +" " + startTime);
            DateTime endDateTime = DateTime.Parse(endDate +" "+ endTime);

            int result1 = DateTime.Compare(startDateTime, DateTime.UtcNow);
            int result2 = DateTime.Compare(DateTime.UtcNow, endDateTime);

            string relationship;

            if (result1==-1 && result2 == -1)
            {
                relationship = "Sytem time is fall under give range";
            }

both returning - 1. Is there is any simple way to get this result?

Santhosh
  • 113
  • 1
  • 3
  • 8

0 Answers0