2

I just want to understand this concept and implement it into my application. Since, suppose I have deployed my asp.net mvc web application at US server. and If I am showing the datetime on my one of the page, say in grid control. and consider somebody accessing site from the UK or India Or Gulf then the date time format should be change accordingly. Also the datetime input controls should be behave accordingly. What concept i need to use for this?

Red Swan
  • 15,157
  • 43
  • 156
  • 238
  • 2
    timezone is not a good variant, because in one timezone can be countries with different date formats. The best choise, use the user language from request. – alexmac Jan 17 '14 at 11:17
  • http://msdn.microsoft.com/en-us/library/system.web.httprequest.userlanguages(v=vs.110).aspx should solve your problem. – Zinoex Jan 17 '14 at 11:20

1 Answers1

0

You need to understand where request came from. You can analyze timezone(example Getting the client's timezone in JavaScript), user language or check client ip adress. After that you can use correctly formated date string.

Edit:

interesting topic from msdn: http://msdn.microsoft.com/en-us/library/bz9tc508%28v=vs.90%29.aspx

Community
  • 1
  • 1
Frank59
  • 3,141
  • 4
  • 31
  • 53
  • Why not just using the culture from the browser? – Zinoex Jan 17 '14 at 11:30
  • @Highace2, how can you get culture from request? – Frank59 Jan 17 '14 at 11:40
  • @Frank59 - Thread.CurrentUICulture contains user culture info. – alexmac Jan 17 '14 at 11:54
  • @ Alexander, i think that Thread.CurrentUICulture contains server culture settings. But may be parameter enableClientBasedCulture in web.config change this situation. – Frank59 Jan 17 '14 at 12:10
  • 1
    @Frank59, Thread.CurrentUICulture contains culture for the current user context. For the asp.net web application this context initialized from request header params. And yes, enableClientBasedCulture can change this behavoir. – alexmac Jan 17 '14 at 12:23
  • @Frank59 Maybe use HttpRequest.UserLanguages? – Zinoex Jan 17 '14 at 15:27