-1

I am having trouble creating a Count UP timer. On the web page is a clock and also a time stamp of an event (displayed from a text file on a label). This all works fine. However, I would like to have a timer that counts UP from the time stamp on the label. I would like to do this on c#. I have tried doing span and timestamp diff, but it doesn't work with a text file. I appreciate any input.

Brad Jarrett
  • 109
  • 3
  • 11
  • Tell us what you have tried so far and what didn't work. – Matt Hogan-Jones Apr 21 '17 at 15:30
  • I have tried using timestamp diff to subtract the current timer from the time stamp. – Brad Jarrett Apr 21 '17 at 15:38
  • If you're doing this on a web page you most likely are going to end up doing this in javascript; this may give you some direction: [Count Up Timer in JS](http://stackoverflow.com/questions/5517597/plain-count-up-timer-in-javascript) – Mad Myche Apr 21 '17 at 15:51
  • I'll try it, will respond after some testing – Brad Jarrett Apr 21 '17 at 16:01
  • When asking a question on SO, always include any relevant code you have already tried so we can see what you're actually doing. Don't just say "I've tried doing X" because that doesn't help us to help you. Read the FAQ. – Matt Hogan-Jones Apr 21 '17 at 16:10
  • Matt, normally I do, however I am more confused about how to do it and the code doesn't mean much to experienced programmers. I was trying to get direction as I am new at c#. I will certainly post the code next time, my apologies. – Brad Jarrett Apr 22 '17 at 14:58

1 Answers1

0

I was able to accomplish this with the following code:

 string ALARMTIME = File.ReadLines(@"Filepatt").Skip(4).Take(1).First(); 
 lblPastTime.Text = ALARMTIME; string ALARMDATETIME = 
 File.ReadLines(@"Filepath").Skip(37).Take(1).First(); 

 DateTime.Now.AddHours(-5).ToString(); //Calculate time zone on count up 
 timer 
 string currenttime2 = DateTime.Now.AddHours(-5).ToString(); TimeSpan 
 duration 
 = DateTime.Parse(currenttime2).Subtract(DateTime.Parse(ALARMDA‌​TETIME)); 
 lblElapsedTime.Text = duration.ToString();
Brad Jarrett
  • 109
  • 3
  • 11