DateTime Now = DateTime.Now; TimeSpan TS = Now.TimeOfDay; String Time1 = Now.ToShortTimeString(); String Time2 = Now.ToLongTimeString(); if (timeFrom.CompareTo(timeTo) > 0) { returnMessage2 += "Time From is bigger than Time To <br />"; }
DateTime now = DateTime.Now; DateTime from = new DateTime(2014, 2, 3, 8, 31, 0); if (now.TimeOfDay > from.TimeOfDay) { Console.WriteLine("After FROM time"); }
DateTime FromDate = DateTime.Now.AddDays(-1); //2/2/2014 5:41:50 PM DateTime ToDate = DateTime.Now.AddDays(2); //{2/5/2014 5:41:50 PM} int value= DateTime.Compare(ToDate ,FromDate); // 1 means To date is greater // -1 lesser // 0 equal
DateTime now = DateTime.Now; DateTime tomorrowSameTime = now + TimeSpan.FromDays(1); if(tomorrowSameTime > now) { // That's the desired behaviour. } else if(tomorrowSameTime < now) { // Something's wrong with the spacetime as we know it. } else { // Identical times intentionally ignored. }
string returnMessage2 = string.Empty; DateTime Now = DateTime.Now; TimeSpan TS = Now.TimeOfDay; String Time1 = Now.ToLongTimeString(); String Time2 = Now.ToLongTimeString(); if (Time1.CompareTo(Time2) >= 0) { returnMessage2 += "Time From is more than Time To, please re-select"; }
DateTime.Now
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)