• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 878
  • Last Modified:

Detect local date time format

I have an app that relies on custom date/time formatting, and thus I need to detect what date/time format the local machine is running, i.e. is it 12 hour or 24 hour time format and is the date dd/mm or mm/dd. I'm amazed I can't find any info about this anywhere.
1 Solution
why do you need to detect the local machine date/time format for? Just retrieve the datetime and put it in your mask (equal to your format mask), then compare it with your format. No need to know what the local machine formats the date and time as.
This is the only thing that I was able to find:


Look for:

Sure, there's a simpler way to go!

Just place a <pages culture="Auto" /> element in your Web.config (under the system.web element) and each user will get the dates formatted to their own preferences.

If you want all users to get a dd/mm/yyyy format, just write <pages culture="fr-FR" /> for instance...

It sounds like you are attempting to do some localization printing.
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:

Dim sortDate As String = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern

It will give give you current windows date format

ShaunDumasAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now