1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

to show the currrent time as in task bar for each regional settings

Discussion in 'C#' started by parassaini, Sep 30, 2010.

  1. parassaini

    parassaini New Member

    Sep 30, 2010
    Likes Received:
    Trophy Points:
    In some project i need to display the current time as shown in taskbar. I have tried the code below
    CultureInfo p = CultureInfo.CurrentCulture;
    DateTime dt = DateTime.Now;
    string t = dt.ToString("T", p);
    My current time is 3:32 (According to my system's taskbar) and this code displays as 3:32:45. it should show exactly 3:32
    My current regional setting is (English United States). I have customized the time format to H:mm:ss by clicking customise button in regional settings from control panel.
    If i change the customized setting then this change is reflected in task bar and this must reflect in the code above, Now i customize the setting to hh:mm:ss tt, task bar displays 03:40 AM and code shows 03:40:28 AM. seconds should not be displayed.

Share This Page