Click here to Skip to main content
15,918,333 members
Please Sign up or sign in to vote.
1.20/5 (2 votes)
See more:
hello ,..

I need help Please
I use this article to Globalization and Localization my website

Globalization and localization demystified in ASP.NET 2.0[^]



This article is very Good and work with me perfectly

but my problem is about Date Time;

when i run my website and change the language All website is localized Except (DateTime)

I using this Code do display date in master page


lbldate.Text = DateTime.Now.Day.ToString() + "/"+
DateTime.Now.Month.ToString() + "/" +DateTime.Now.Year.ToString();

lblday.Text = DateTime.Now.DayOfWeek.ToString();

Please Help me ....


my second problem the arabic language in dropdownlist does not appear
it is apppear in (small squares ) Why?????????

Thanks Very much ,...
Posted

Hi
toString() method accepts a format provider. So have like this
C#
DateTimeFormatInfo info=CultureInfo.CurrentCulture.DateTimeFormat;
DateTime.Now.Day.ToString(info);

In your case, use the correct culture info instead of current culture
 
Share this answer
 
To localize the DateTime structures, what you need is less code. Something along the lines of:
lbldate.Text = DateTime.Now.ToString("d");
lblday.Txt = DateTime.Now.ToString("dddd");


See http://msdn.microsoft.com/en-us/library/az4se3k1(v=VS.90).aspx[^]

(Sorry, can't help with the Arabic question off the top of my head.)

[]Loren
 
Share this answer
 
Thanx Albin ..................

Now , it is Work but numbers of date is displayed in English languages in both cultures
(english and arabic)


Thanx Lorenkins ............ Amazing Link .



( i have two culture English and Arabic )
Finally , only the numbers is always display in English language in (both cultures)
but The Day name Work Correctly .
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-May-13 1:04am    
Not an answer.
—SA

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