DateTime Format Problem with Turkish Locale dd.MM.yyyy

Task: Get a Date string and convert it to DateTime object in the form of “dd.MM.yyyy”.

Problem: No matter what you do, you can not change the default yyyy/dd/MM (or yyyy/MM/dd) format.

Yes, this was my case while I was trying to convert the format of Date value, and then record that value into my database. I wanted to have my date values in “dd.MM.yyyy” format in the database. Is it too much to ask? Anyway let's get going…

Methods I tried:


DateTimeFormatInfo dtfi = new DateTimeFormatInfo();

dtfi.ShortDatePattern = “dd.MM.yyyy”;

dtfi.DateSeparator = “.”;

DateTime date = Convert.ToDateTime(“13.01.2013”, dtfi);


IFormatProvider theCultureInfo = new System.Globalization.CultureInfo(“tr-TR”, true);

DateTime date;
date = DateTime.ParseExact(“13.01.2013”, “dd.MM.yyyy”, theCultureInfo);
Non of the methods above seem to be working, and most of the samples on the internet were coming down to these 2.

Then I found out that I had not set the “culture” info on web.config file. So I added uiCulture=”tr-TR” culture=”tr-TR” values into <globalization /> tag and boom! it was done:)

Hope this helps someone.

Good luck,

Leave a Reply

Your email address will not be published. Required fields are marked *