DATEFORMAT based on reginoal settings

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
 
S

Santi

Hi, try this:

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

MessageBox.Show( date.ToShortDateString() );
 
K

Karunakararao

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.
 
C

Chris Jobson

Try something like
CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern

Chris Jobson
 
F

fd123456

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
 
K

Karunakararao

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top