protected bool getTimeSpan(string timeStr) { //判断当前时间是否在工作时间段内 string _strWorkingDayAM = "07:00"; string _strWorkingDayPM = "19:00"; TimeSpan dspWorkingDayAM = DateTime.Parse(_strWorkingDayAM).TimeOfDay; TimeSpan dspWorkingDayPM = DateTime.Parse(_strWorkingDayPM).TimeOfDay; //string time1 = "2017-2-17 8:10:00"; DateTime t1 = Convert.ToDateTime(timeStr); TimeSpan dspNow = t1.TimeOfDay; if (dspNow >= dspWorkingDayAM && dspNow < dspWorkingDayPM) { return true; } return false; }
标签:00,判断,string,TimeSpan,C#,dspNow,班别,DateTime,TimeOfDay From: https://www.cnblogs.com/blossomwei/p/17808277.html