Skip to content Skip to sidebar Skip to footer

Format C# Datetime To Local String Format

I have a DateTime C# object (in a Unity script, targeted for an Android device). I want to retrieve a string representation via .toString() (so w/o any special formatting parameter

Solution 1:

Your assumption about DateTime.ToString is correct. The following code prints 05.10.2014 13:26:36:

Thread.CurrentThread.CurrentCulture = newCultureInfo("de-DE");
DateTimetime= DateTime.Now;
Console.WriteLine(time.ToString());

I'd check what the value of Thread.CurrentThread.CurrentCulture.ToString() is in your environment and ensure that Unity sets it correctly. If it doesn't, you would have to do it yourself.

Post a Comment for "Format C# Datetime To Local String Format"