Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# - How to change culture without changing DateTime format

I have been used Resx file in ASP,net Web Form for implemention of multi language in an site. for changing the language I should change below mesures:

Thread.CurrentThread.CurrentCulture
Thread.CurrentThread.CurrentUICulture

it seems that in new operating systems such as Microsoft Windows 10 , changing Culture may change the DateTime in a same way. it cause a lot of problem for us for example : The saving format for DateTime in database is Anno Domini but it change by changing Culture and save in database by other formats. How should I change the Culture without changing the Date format?

Thanks

like image 306
iman kari Avatar asked Oct 25 '25 20:10

iman kari


1 Answers

I added the following code to my OnLoad of master page to prevent using other cultures calendars

System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat = New CultureInfo("en-GB").DateTimeFormat
like image 92
iSafa Avatar answered Oct 27 '25 10:10

iSafa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!