Regional settings made at the operating system level

K

Karunakararao

Hi All

regional settings made at the operating system level. For example, Canada
uses a dd/mm/yyyy format while the US uses mm/dd/yyyy.

how can i get this type date format :
iam using this code in C#:
System.DateTime.UtcNow.Date.ToString();

Regards
Venu.
 
J

Jon Skeet [C# MVP]

Karunakararao said:
regional settings made at the operating system level. For example, Canada
uses a dd/mm/yyyy format while the US uses mm/dd/yyyy.

how can i get this type date format :
iam using this code in C#:
System.DateTime.UtcNow.Date.ToString();

DateTime.UtcNow.ToString("dd/MM/yyyy");
or
DateTime.UtcNow.ToString("MM/dd/yyyy");

See "custom date and time format strings" in MSDN for more information.
 
N

Nicholas Paldino [.NET/C# MVP]

Venu,

What you can do is use the static CurrentCulture or CurrentUICulture
properties on the Thread class to get the current culture for the thread.
That will return a CultureInfo instance which you can then get the
DateTimeFormat property of to get the datetime format that is set for the
system.

Hope this helps.
 

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