Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7014059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:28:17+00:00 2026-05-27T22:28:17+00:00

I am using the following code to display the elapsed time of a task

  • 0

I am using the following code to display the elapsed time of a task in the status bar in my application.

public void DisplayDuration(TimeSpan duration)
{
    string formattedDuration;

    if (duration.TotalMilliseconds < 2000)
        formattedDuration = string.Format("{0} ms", duration.TotalMilliseconds);
    else if (duration.TotalSeconds < 60)
        formattedDuration = string.Format("{0} sec", duration.TotalSeconds);
    else
        formattedDuration = string.Format("{0} min", duration.TotalMinutes);

    this.TimingLabel.Text = formattedDuration;
}

this.TimingLabel is a label in the statusStrip control in the footer of the winform.

But I get completely different results on Windows XP vs Windows 7

Windows XP:
elapsed Time formatted XP

Windows 7
elapsed Time formatted 7

Why is the units appearing before the time in Windows 7?

I have checked Regional Settings both machines are set to US with same Date Time formatting. Make quite quite sure it is the same code running on both machines.
This is very odd behavior in some very simple code.

As a follow up: I made the following change to my code but still have the same problem:

formattedDuration = string.Format("{0} ms", duration.TotalMilliseconds.ToString()); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:28:18+00:00Added an answer on May 27, 2026 at 10:28 pm

    I think the most likely probably here is a layout issue and not String.Format. Regional settings shouldn’t be a factor here because you’re not asking the TimeSpan to format its value. Instead you’re asking String to format a string “ms” followed by a number. It would be simply a bug if it inverted them in the output.

    What’s much more likely is that the number is being clipped via a bug in the layout constraints of the container. If I look very hard at the screen shot there does appear to be a divider immediately to the left of the ms string.

    Try giving everything a fixed width which is fairly large and see if the correct display comes back.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code to display unhandled exceptions in a WPF application: public
I am using the following code to try and display in a time in
I am using following code to open Android Contacts @Override public void onCreate(Bundle savedInstanceState)
I my application, I display 3 to 4 Screen using following code. main.pushScreen(screen); Now
I'm using following code to display some text and it won't change the font
i am using following code to display remote image with next and previous buttons.
I am using following code to display bitmap in my ImageView. When I try
friends, i am using following code to display bitmap on screen and having next
I am using the following code for display questions and answers from admin. <?php
I'm using the following code to display a 'previous posts' link on my Wordpress

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.