Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DateTime.Now.DayOfWeek.ToString() with CultureInfo

I have the code:

DateTime.Now.DayOfWeek.ToString() 

That give's me the english day of the week name, I want to have the german version, how to add CultureInfo here to get the german day of the week name?

like image 714
PassionateDeveloper Avatar asked Apr 19 '11 13:04

PassionateDeveloper


Video Answer


2 Answers

var culture = new System.Globalization.CultureInfo("de-DE"); var day = culture.DateTimeFormat.GetDayName(DateTime.Today.DayOfWeek); 
like image 81
Diego Avatar answered Sep 20 '22 20:09

Diego


You can use the DateTimeFormat.DayNames property of the german CultureInfo. For example:

CultureInfo german = new CultureInfo("de-DE"); string sunday = german.DateTimeFormat.DayNames[(int)DayOfWeek.Sunday]; 
like image 39
Jean-Baptiste Avatar answered Sep 20 '22 20:09

Jean-Baptiste