Live2D 看板娘 / Demo

c# 返回时间差

  #region 返回时间差
        public static string DateDiff(DateTime DateTime1, DateTime DateTime2)
        {
            string dateDiff = null;
            try
            {
                TimeSpan ts1 = new TimeSpan(DateTime1.Ticks);
                TimeSpan ts2 = new TimeSpan(DateTime2.Ticks);
                TimeSpan ts = ts1.Subtract(ts2).Duration();
                string day = ts.Days.ToString(), hours = ts.Hours.ToString(), minutes = ts.Minutes.ToString(), seconds = ts.Seconds.ToString();
                dateDiff = day + "" + hours + "" + minutes + "" + seconds + "";
            }
            catch
            {

            }
            return dateDiff;
        }
        #endregion

 

posted @ 2016-11-30 08:55  MChuang  阅读(245)  评论(0编辑  收藏  举报