locked
Date Format in Swedish Culture RRS feed

  • Question

  • User-1917713218 posted

    Hello All,

     

    In my application, gridview is used to display data.

    But the problem is that I want to show date in “dd-MM-yyyy hh:mm tt”.

    In English culture it displays right format.

    But when I change current culture to Swedish the date format changes to “dd-MM-yyyy hh:mm”

    means it didn't displays “AM/PM” in Swedish.

    There is not a single line change in code to get data and display in gridview.

    So if any one of you have faced same problem then please give me appropriate solution for the same.

     

    Friday, October 15, 2010 7:23 AM

Answers

  • User1508394307 posted

    Because they use 24 hours clocks and AM/PM make no sense there.

    If you always need to show time in the same format use the same culture in both cases

    CultureInfo ci = new CultureInfo("en-GB");
    string dateGB = DateTime.Now.ToString("dd-MM-yyyy hh:mm tt", ci); 

    Hope this helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 15, 2010 8:26 AM