• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 626
  • Last Modified:

Difference in seconds between two datetimes, C# asp.net webpage

I am trying to calculate the seconds between two date times in Asp.net with C# as the language for a webpage I am developing. My goal is to calculate a datetime I have marked as "indt"(an earlier datetime) and the current time which i have marked as "inct". How do you go about getting this value in seconds as an Integer.
Exampe
    inct-indt= x seconds
If any other information is needed just ask.
0
tomcalef
Asked:
tomcalef
1 Solution
 
DarkoLordCommented:
TimeSpan ts = inct - indt;
MessageBox.Show(ts.TotalSeconds.ToString());
0
 
multithreadingCommented:
int seconds = (int)(inct-indt).Seconds;
0
 
sabeeshCommented:
DateTime date = DateTime.Now;
        DateTime dte = DateTime.Now.AddDays(1);
        TimeSpan span =  dte.m- date;
        int s = span.Milliseconds;
0
 
multithreadingCommented:
int seconds = (int)Math.Round((inct-indt).TotalSeconds);
0
 
tomcalefAuthor Commented:
I would have split the points if it wasnt for the first answer working perferct, Thanks alot guys.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now