Home > Net >  How to judge whether the current time within a specified time
How to judge whether the current time within a specified time

Time:10-04

For example, a task at 23:30 start 03:30 end
How to judge whether the current time in the task time

CodePudding user response:

Datetime and timespan can directly compare the size

CodePudding user response:

Time, datetime.com pare said, or calculate the difference timespan, poor judgment value attribute

CodePudding user response:

Timestamp
 TimeSpan start=TimeSpan. Parse (" 30 "); 
TimeSpan end=TimeSpan. Parse (" 03:30 ");
Var q=a DateTime. Now. TimeOfDay;
Var result=! (q & lt;=start & amp; & Q & gt;=end);
Console. WriteLine (result);

CodePudding user response:

DataTime set the starting time of the next time the begin, end set over time, and then use a DateTime. Now. The sub minus the start time and end time, if the resulting value greater than 0, is greater than the start or end time, it is ok to this time in accordance with the business judgment,

CodePudding user response:

We can use jutils - isDuringDate JavaScript libraries commonly used function to implement

Method of use:
JavaScript to compare whether the current time within a specified time period

Source:

CodePudding user response:

datediff

CodePudding user response:

Datetime1 - datetime2=what a TimeSpan and then judge the minutes is ok, so old post also out,
  •  Tags:  
  • C#
  • Related