How can i get the date formatted according to the regional settings made at the operating system le

K

Karunakararao

Hi All,

How can i get the date based on Regional settings .
how can i get the date format using C# .NET

" The date displayed in the date/time field should be formatted according to
the regional settings made at the operating system level. For example,
Canada uses a dd/mm/yyyy format while the US uses mm/dd/yyyy. The month and
day should be padded with zeros. In other words, use 01/01/2005 rather than
1/1/2005. The date will always appear as a range"
Please help me

Regards
venu.
 
N

Nicholas Paldino [.NET/C# MVP]

Karunakararao,

You can get an instance of the DateTimeFormatInfo class from the static
CurrentInfo property on the DateTimeFormatInfo class. Once you have that,
you can pass that to the ToString method to get a string representation of
the date in the local format.

Hope this helps.
 
M

Morten Wennevik

Is that really necessary? If you use DateTime.ToShortDateString() it will
automatically format the date in the format specified in the operating
system.

Happy coding!
Morten Wennevik [C# MVP]
 
N

Nicholas Paldino [.NET/C# MVP]

Morten,

Necessary, no. The ToShortDateString would work just fine in this
scenario.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Is that really necessary? If you use DateTime.ToShortDateString() it will
automatically format the date in the format specified in the operating
system.

Happy coding!
Morten Wennevik [C# MVP]
 

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