关于时间的问题。。

为你快乐 2005-10-11 05:58:54
知道DateTime1和DateTime2两个时间的Double形式,DateTime2比DateTime1大,如何在Double形式下DateTime2-DateTime1后知道两者之间的秒数。。。
...全文
92 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
jxjjljf 2005-12-28
  • 打赏
  • 举报
回复
m
mathsword 2005-10-11
  • 打赏
  • 举报
回复
晕,这么多星星跟我抢
mathsword 2005-10-11
  • 打赏
  • 举报
回复


TimeSpan ts=(TimeSpan)(DateTime2-DateTime1)
ts.TotalSeconds



TimeSpan.TotalSeconds
获取以整秒数和秒的小数部分表示的此实例的值


孟子E章 2005-10-11
  • 打赏
  • 举报
回复
msdn.microsoft.com/library/en-us/cscon/ html/vctskcodedeterminingspanbetweentwodatesvisualc.asp

Determining the Span Between Two Dates
孟子E章 2005-10-11
  • 打赏
  • 举报
回复
Determining the Span Between Two Dates


Example
DateTime oldDate = new DateTime(2002,7,15);
DateTime newDate = DateTime.Now;

// Difference in days, hours, and minutes.
TimeSpan ts = newDate - oldDate;
// Difference in days.
int differenceInDays = ts.Days;

Console.WriteLine("Difference in days: {0} ", differenceInDays);看了些例子,发现什么都要NEW才可以用:(,真麻烦日期间的间距要这样才可以得出来,麻烦哦。int differenceInDays = ts.Days;得出两个日期间相差的天数,int diffhour= ts.Hours;得出的却不是两个日期间相差的总小时数
孟子E章 2005-10-11
  • 打赏
  • 举报
回复
Determining the Span Between Two Dates


Example
DateTime oldDate = new DateTime(2002,7,15);
DateTime newDate = DateTime.Now;

// Difference in days, hours, and minutes.
TimeSpan ts = newDate - oldDate;
// Difference in days.
int differenceInDays = ts.Days;

Console.WriteLine("Difference in days: {0} ", differenceInDays);看了些例子,发现什么都要NEW才可以用:(,真麻烦日期间的间距要这样才可以得出来,麻烦哦。int differenceInDays = ts.Days;得出两个日期间相差的天数,int diffhour= ts.Hours;得出的却不是两个日期间相差的总小时数
bitsbird 2005-10-11
  • 打赏
  • 举报
回复
TimeSpan t =DateTime1-DateTime2;
t.Milliseconds

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧