Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello sir,
help me to get solution for date format ?
i have a dropdownlist which is bind the different cultures
english, polski, czech republic, etc...
in project we used this format for date => MMM dd, yyyy
all cultures are completely work and display date with this format "Sep 11, 2014"
except one culture "Czech republic".
czech republic diplays with this format "09 11, 2014"
i search on google with taken more time bt i only got that
this culture havae only two formats d.m.yy, d.mm.yyyy, dd.mmmm.yyyy
this culture does not support month's short name.
like, jan, feb,sep, oct,etc..
and i complsry to display this date format in project
pls help me to get short month name with czech republic
pls give me some ideas, hints, that how to solved this ??
thanx
Posted
Comments
Tomas Takac 3-May-15 15:36pm    
AFAIK there are no official abbreviations for month names in Czech language hence the numbers. If you really need a three letter codes for month names you need to invent them yourself. But there is no guarantee they will be universally recognized. I would stick with whatever .NET framework is providing.

 
Share this answer
 
Comments
Abhinav S 4-May-15 2:58am    
5!
Maciej Los 4-May-15 3:30am    
Thank you ;)
As I already said in my comment Czech language doesn't have a standardized list of month name abbreviations. That is most probably the reason Microsoft chose to use roman numerals for MMM format. But you create your own format to support short month names.
C#
var czechCulture = new System.Globalization.CultureInfo("cs-CZ");
var customDateTimeFormatInfo = (System.Globalization.DateTimeFormatInfo)czechCulture.DateTimeFormat.Clone();

var czechMonthAbbreviations = new [] {
"led.","úno.","bře.","dub.","kvě.","čvn.","čvc.","srp.","zář.","říj.","lis.","pro.",""
};

customDateTimeFormatInfo.AbbreviatedMonthNames = czechMonthAbbreviations;
customDateTimeFormatInfo.AbbreviatedMonthGenitiveNames = czechMonthAbbreviations;

DateTime.Now.ToString("dd MMM yyyy", customDateTimeFormatInfo).Dump();

These abbreviations should be understandable but be aware this is not how you would write date in Czech. Technically you should set the genitive form as well but trying to squeeze that into 3 letter would produce something like "čce." for July which would make the reader think hard at first and then roll his eyes.
 
Share this answer
 
Comments
Maciej Los 4-May-15 3:41am    
I didn't know that MS does not support custom date format ("MMM") for Czech localization (even if it does support for Poland). +5!

I found interesting links, please see (and use it in your answer - if you wish):
https://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.abbreviatedmonthnames%28v=vs.110%29.aspx
https://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.abbreviatedmonthgenitivenames%28v=vs.110%29.aspx
Tomas Takac 4-May-15 3:57am    
thanks Maciej, localization is always tricky
You asked a similar question here[^] before.
Try
C#
Console.WriteLine(date1.ToString("MMMM dd YYYY",CultureInfo.CreateSpecificCulture("cs-CZ")));
 
Share this answer
 
Comments
Manish Dalwadi 4-May-15 0:46am    
which code you given , it will display like "octomber", not "oct"
i want month like "oct", "sep" in czech republic culture
Maciej Los 4-May-15 1:52am    
So, remove one "M" from ToString method ;)
Tomas Takac 4-May-15 2:54am    
Wrong, this doesn't solve the problem at all.
Maciej Los 4-May-15 2:56am    
What's wrong, Tomas?
Tomas Takac 4-May-15 3:01am    
Please read the question carefully. OP is asking why MMM format is not giving a month abbreviation for cs-CZ. Telling him to use MMM date format doesn't really help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900