Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I need the current Datetime minus myDate1 in seconds.

DateTime myDate1 = new DateTime(1970, 1, 9, 0, 0, 00);
DateTime myDate2 = DateTime.Now;

TimeSpan myDateResult = new TimeSpan();

myDateResult = myDate2 - myDate1;

.
.
I tried different ways to calculate but to no effect.

TimeSpan mySpan = new TimeSpan(myDate2.Day, myDate2.Hour, myDate2.Minute, myDate2.Second);

.
The way it's calculated doesn't matter, the output should just be the difference these to values in seconds.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
542 views
Welcome To Ask or Share your Answers For Others

1 Answer

Code:

TimeSpan myDateResult = DateTime.Now.TimeOfDay;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...