How to convert a DataTime value to a specific culture using C #?

I have a DateTime value = 3/24/2011 6:25:29 PM saved I am public DateTime propertie LastChange how can I convert it to a German Datetime form? for example: 3/24/2011 18:25:29 ?

+4
source share
4 answers

You can write

 date.ToString(new CultureInfo("de-DE")) 
+4
source

Just use ToString and specify your custom format string as shown below

 LastChange.ToString("M/dd/yyyy HH:mm:ss") 
+3
source
0
source

Just replace your culture

  System.DateTime now = System.DateTime.Now; System.Console.WriteLine(now); System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo(1031); // de-DE System.Console.WriteLine(now.ToString(culture)); 
0
source

Source: https://habr.com/ru/post/1345081/


All Articles