DATEFORMAT based on reginoal settings

  • Thread starter Thread starter Karunakararao
  • Start date Start date
K

Karunakararao

Hi all
How can i get the "Short Date Format" from regional and language
options
Like "MM/dd/yyyy"
how can get this type of format based regional settings;
I wnat to show this format in web application.

Regards
Venu
 
Hi, try this:

CultureInfo culture = new CultureInfo( "en-US" );
DateTime date = DateTime.Now;
System.Threading.Thread.CurrentThread.CurrentCulture = culture;

MessageBox.Show( date.ToShortDateString() );
 
Hi i want like this I dont want dates "09/02/2004"
I want format lke this "dd/mm/yyyy"
from regional settings

Regards
Venu.
 
Try something like
CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern

Chris Jobson
 
Hi Karunakararao,

Add this at top of code :

using System.Globalization;

Then try this :

MessageBox.Show(CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern);

You can replace ShortDatePattern with LongDatePattern,
FullDateTimePattern or whatever suits your needs. Use Intellisense to
discover more patterns.

HTH,
Michel
 
Hi Chris Jobson

Thanks for your suggestion, the one which you mentioned is working only in
Windows application but not in WebApp.Any clue?

Regards
Venu
 
Back
Top