Forum Xamarin.Forms

Getting datetime format from CultureInfo

I need to show some DateTime on a few labels.
I have tried to do this using a ValueConverter, and utilize the CultureInfo object to get the correct format like this:

localDateTime.ToString("g", culture);  //g is format for localized shortformat.

Now, this works perfectly if people have not tampered with the settings on their phones.
People in Denmark, however, tend to often have their phones set to english setup (en-US), and just correct the timezone and timeformat.

Which result in getting me something like 12/31/2015 03:25 PM instead of 31-12-2015 15:25

How do I get the correct format that the user has set, from the phone??? I Assume it is easily accessible somewhere.

Best Answers


  • BoVisfeldtBoVisfeldt DKMember ✭✭

    I guess you are both right, I just assumed that it would be a standard thing in Xamarin, as it is standard functionality in .NET.
    I will go the Native way as you both surgest.

    Thanks for taking the time to answer me.

  • DanielLDanielL PLInsider ✭✭✭✭

    @BoVisfeldt You're right. It should definitely be an out of the box solution for such things (getting system language culture and getting system locale culture).

Sign In or Register to comment.