//C#对时间差有一个专门封装的类: TimeSpan.cs;
DateTime marriedTime = Convert.ToDateTime("2021-07-01 08:08:08");
DateTime nowTime = DateTime.Now;
TimeSpan timeSpan1 = new TimeSpan(marriedTime.Ticks);
TimeSpan timeSpan2 = new TimeSpan(nowTime.Ticks);
TimeSpan timeSpanSub = timeSpan1.Subtract(timeSpan2).Duration();
//timeSpanSub.Days:相差天数 timeSpanSub.Hours:相差小时 timeSpanSub.Minutes:相差分钟
Debug.Log($"We are married: {timeSpanSub.Days} {timeSpanSub.Hours} {timeSpanSub.Minutes}");
Unity3d 计算日期差、时间差
原创
©著作权归作者所有:来自51CTO博客作者S人狂魔鼠尾草的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章