Friday, 19 March 2021

MVC - C# - Check if time is greater than something

 Watch this example on YouTube


 

            TimeSpan startSomething = new TimeSpan(8, 0, 0);
            TimeSpan endSomething = new TimeSpan(16, 0, 0);
            TimeSpan now = DateTime.Now.TimeOfDay;
            if ((now > startSomething) && (now < endSomething))
            {
                //do something here
            } 

No comments:

Post a Comment