how to find Seconds elapsed ? ....

  • Thread starter Thread starter Prabhu
  • Start date Start date
P

Prabhu

Hi,

Can any one help me getting Seconds elapsed from a given date time to
current time in .Net?.

for e.g.

Suppose assume a given time date time "01-Jan-2000 00:00:00",
I should get the number of seconds elapsed from the given date time to
current date time.

Thanks & Regards
Prakash K. Prabhu
 
Hi,

DateTime then = new DateTime ( ... ); // the old date
double seconds = (DateTime.Now - then).TotalSeconds;

//the substraction of two datetime is a TimeSpan , if you want that the
autocomplete works on VS you shoudl do this:
double seconds = ( (TimeSpan) (DateTime.Now - then)).TotalSeconds;

Cheers,
 
Back
Top