在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
public bool IfTime(string StartTime, string EndTime) { DateTime dt1 = Convert.ToDateTime(StartTime); DateTime dt2 = Convert.ToDateTime(EndTime); if (DateTime.Compare(dt1, dt2) < 0) { //开始时间 < 结束时间 (执行以下语句),,说明开始时间晚 return true; } return false; } starttime= DateTime.Now.ToShortTimeString().ToString();
public int Time_Minute_diff(string StartTime, string EndTime)
/// <summary> /// 获得固定年月日,时和分不固定 : 2019-01-01 00:00:00 /// </summary> /// <returns></returns> public DateTime GetFixedDateTime() { string time1 = DateTime.Now.ToShortTimeString(); //16:50 //yyyy-MM-dd hh:mm:ss //2019-01-01 16:34:00 string Ymd = "2019-01-01 "; string Hour = DateTime.Now.Hour.ToString(); string Minute = DateTime.Now.Minute.ToString(); return Convert.ToDateTime(Ymd + Hour + ":" + Minute + ":" + 00); }
/// <summary> /// 获得固定年月日,时和分不固定 : 2019-01-01 00:00:00 /// </summary> /// <returns></returns> public DateTime GetFixedDateTime(string Hour = "", string Minute = "") { string time1 = DateTime.Now.ToShortTimeString(); //16:50 //yyyy-MM-dd hh:mm:ss //2019-01-01 16:34:00 string Ymd = "2019-01-01 "; if (Hour == "") { Hour = DateTime.Now.Hour.ToString(); Minute = DateTime.Now.Minute.ToString(); } return Convert.ToDateTime(Ymd + Hour + ":" + Minute + ":" + 00); }
[HttpPost] public int DeleteSingle(string id) { //删除时候只删除24小时内的 var now = DateTime.Now; var model = _t_WeeklyManageBus.GetTheData(id); if (model != null) { TimeSpan span = now.Subtract(model.CreateTime); //当前时间-去创建时间 if (span.Days > 1) //1天后 { return _t_WeeklyManageBus.DeleteSingle(model); } } return -1; }
|
请发表评论