Regional DateTime Format Setting

{This Post was Posted by My Collegue i think this will be use full so posting the same in my Blog }

Now a days we get lot many problems with DateTime Format, during the coding time it works well with what ever the approach one goes with but when it was deployed or changed from one system to another, So the solution is:

Use this peace of code in page_load or where ever you need which should take the server time which will be taken as per the given format

Microsoft.Win32.Registry.SetValue(@”HKEY_CURRENT_USER\Control Panel\International”, “sShortDate”, “dd-MM-yyyy”);

now if you want to check your system time

Respose.WriteLine(“The result is:” + DateTime.Now.ToShortDateString());

The result is: 16-07-2011

Before this the Actual format would be 07/16/2011

So, from the above code we get all the dates only in the above given format with in the page

{ refer here for original post }


About kakani santosh kumar

Working as Software Engineer in Prithvi Information Solutions having 3 years of Experience in Dotnet Framework ranging from 1.1 to 3.5
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s