In my website, I use DateTime.TryParse()
to parse datetime data. My problem is I don't know the format. For example, if the user uses US format, the format would be mm/dd/yyyy
, while user uses UK, it would use the dd/mm/yyyy
format.
I think the format is based on their computer settings. So, how can I parse string using the format from their computer?
Try to set
<system.web>
<globalization culture="auto" />
<system.web>
in Web.Config
and use CultureInfo.CurrentCulture
for getting current culture.
Also you can check HttpContext.Request.UserLanguages
for getting additional info about client.