Thursday, March 29, 2012

Set DateTime format

Can I set that DateTime format accept "dd/MM/yyyy" format of date?Hello, Where do you want to set them ? in a textbox, where ?

regards.
Hello, what you need to do is to convert the string into a dateTime right ?

Check this link please:
DateTime Constructors

regards.
User will enter date in format "dd/MM/yyyy" and I need to convert that user input into DateTime, without changing CultureInfo.

??
Yes


Edited by haidar_bilal - Please place your code within< code > and < /code > tag. Thank you.

I found solution. U put this in Application_BeginRequest method in Globa.asax.cs

DateTimeFormatInfo dtf = new DateTimeFormatInfo();
dtf.ShortDatePattern = "dd/MM/yyyy";
CultureInfo culture = CultureInfo.CreateSpecificCulture("en-GB");
culture.DateTimeFormat = dtf;
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;

CurrentCulture is still en-GB and datetime format is dd/MM/yyyy
Glad you solved your problem.

regards.

0 comments:

Post a Comment