Powered By Blogger

Tuesday, December 15, 2009

Set the DateFormat in Indian Format (dd-MM-yyyy)


To View Date in Indian Format (dd-MM-yyyy)

By Fixing the Date format(Our desired) throughout the Application By doing this in .ASAX File

In Global.asax

using System.Globalization;
using System.Threading;

protected void Application_BeginRequest(Object sender, EventArgs e)
{
CultureInfo inf = new CultureInfo("en-US");
inf.DateTimeFormat.ShortDatePattern = "dd--MM--yyyy";
inf.DateTimeFormat.DateSeparator = "--";
Thread.CurrentThread.CurrentUICulture = inf;
Thread.CurrentThread.CurrentCulture = inf;
}

In Default.aspx

Label4.Text = DateTime.Now.ToShortDateString();




No comments:

Post a Comment