#region 返回时间差 public static string DateDiff(string strDateTime) { DateTime DateTime1 = Convert.ToDateTime(strDateTime),DateTime2 = DateTime.Now; string dateDiff = null; try { TimeSpan ts = DateTime2 - DateTime1; if (ts.Days >= 1) { dateDiff = DateTime1.Month.ToString() + "月" + DateTime1.Day.ToString() + "日"; } else { if (ts.Hours > 1) { dateDiff = ts.Hours.ToString() + "小时前"; } else { dateDiff = ts.Minutes.ToString() + "分钟前"; } } } catch { } return dateDiff; } #endregion
时间: 2024-10-11 16:38:20