Hi there,
There are many ways to achieve the desired format of date and time, only difference is logical.
There is an in-built feature Microsoft has provided in .NET framework called CultureInfo that resides in System.Globalization namespace, which gets rid of all your problems. It not only solves date problem as many have always had in past but also it takes of local currency format, time format etc.
If you want specific date format for a page
just set these two properties of the webform in Design mode using Property Window.
1.Culture
2.uiCulture.
as in India We follow British Date format(i.e. "dd/MM/yyyy"), I'll just set these two properties to "en-GB English (United Kingdom)"
and what else, you have to forget all the additional coding for this page in order to show the local date format.
The Best part of it is, you will not even need to change the date format while inserting it into database, .Net framework is smart enough to take care of it.
here I am putting a link which will give a brief and useful information in this regard.
http://www.c-sharpcorner.com/Code/20...lAppsInNet.asp
Vinod Pawar
Software Developer
India