Convert Difference between 2 times into Milliseconds?

后端 未结 11 2182
梦毁少年i
梦毁少年i 2020-12-06 09:11

I have two masked TextBox controls and was wondering how I\'d go about getting the time in each one and then converting the difference into milliseconds. Like, say in tb1 I

11条回答
  •  佛祖请我去吃肉
    2020-12-06 09:31

        public static Int64 GetDifferencesBetweenTwoDate(DateTime newDate, DateTime oldDate, string type)
        {
            var span = newDate - oldDate;
            switch (type)
            {
                case "tt": return (int)span.Ticks;
                case "ms": return (int)span.TotalMilliseconds;
                case "ss": return (int)span.TotalSeconds;
                case "mm": return (int)span.TotalMinutes;
                case "hh": return (int)span.TotalHours;
                case "dd": return (int)span.TotalDays;
            }
            return 0;
        }
    

提交回复
热议问题