title: What is the proper way to format a TimeSpan as a countdown timer?
body: <p>I have a timer that runs on the website. It will retrieve a timespan of how long a user has until their order expires. For the most part this works fine, the server will return the initial time remaining and the javascript will do the countdown. So it displays</p>
  
  <p><code>2:30</code> <code>2:29</code> <code>2:28</code></p>
  
  <p>Then for some reason, on some of the page loads (seems to happen when the timer has less than 60 seconds remaining), the formatting turns to</p>
  
  <p><code>-1:0-45</code> <code>-1:0-46</code> <code>-1:0-47</code></p>
  
  <p>This is the code responsible for formatting the timespan:</p>
  
  <pre><code>&lt;%= (TimeRemaining.TotalMinutes - 1).ToString("N0") %&gt;:&lt;%= TimeRemaining.Seconds.ToString("N0").PadLeft(2,'0') %&gt;
  </code></pre>
  
  <p>I've also just tried the following with the same result.</p>
  
  <pre><code>&lt;%= String.Format("{0:0}:{1:00}", TimeRemaining.TotalMinutes-1, TimeRemaining.Seconds)%&gt;
  </code></pre>
  
  <p>I also have a check on the TimeRemaining, if the TotalSeconds is &lt;= 0, then it just returns a <code>new TimeSpan(0)</code>, so it should never be going negative. It's not the javascript thats screwing up the countdown, because I can disable it and still see the messed up formatted time.</p>
  
  <p>Is there a better/cleaner way to do this?</p>