using System;
using System.Collections.Generic;
using System.Text;
namespace TestDatetimeSubtract
{
class Program
{
static void Main(string[] args)
{
//只测试日期时间的时间部分,每天的8点---10点之间
DateTime PushStartTime = new DateTime(2017, 3, 1, 8, 0, 0);
DateTime PushEndTime = new DateTime(2017, 3, 1, 10, 0, 0);
long ss = DateTime.Now.TimeOfDay.Subtract(PushStartTime.TimeOfDay).Ticks;
long ss1 = DateTime.Now.TimeOfDay.Subtract(PushEndTime.TimeOfDay).Ticks;
if (DateTime.Now.TimeOfDay.Subtract(PushStartTime.TimeOfDay).Ticks > 0
&& DateTime.Now.TimeOfDay.Subtract(PushEndTime.TimeOfDay).Ticks < 0)
{
Console.WriteLine("ok");
}
Console.Read();
}
}
}