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

    Joined:
    Sep 30, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hi,
    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);
    Console.Write(t);
    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

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice