[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 707
  • Last Modified:

regional settings - ASP and IIS

How will IIS treat the regional language setting ? I have a web app, within the asp page, I have certain date fields. These are bound to datetime fields (ado types) in com objects. When a user enters 01/02/2008 and the regional setting is mm/dd/yyyy then it will be sent
to sql server as January 02 2008. My question is what will happen if a user logged from UK saves a record ? Will this be February 1st 2008 (dd/mm/yyyy) in the business object? These are com dlls. My webserver control panel regional setting has a format of mm/dd/yyyy.
0
tech_question
Asked:
tech_question
1 Solution
 
slamhoundCommented:
This is always a big issue as I'm Australian (dd/mm/yyyy) and MS defaults everything to the US date format (mm/dd/yyyy) and I've developed a site for selling products to 15 different countries. I've found the best thing to do is to pass all dates through a function that forces their format. Two that I use regularly are included below:

Public Function DateToSQL( strDate )
      ' Takes date of form D/M/YYYY and converts to YYYY-MM-DD format for SQL use
      Dim aDate
            
      aDate = Split( strDate, "/" )
      
      If Len( aDate(1) ) = 1 Then
            aDate(1) = "0"& aDate(1)
      End If
      If Len( aDate(0) ) = 1 Then
            aDate(0) = "0"& aDate(0)
      End If
      
      DateToSQL = ""& aDate(2) &"-"& aDate(1) &"-"& aDate(0)
      
End Function

Public Function ForceDate()
    ForceDate = Day(Date()) & "/" & Month(Date()) & "/" & Year(Date())
End Function

On your site, you need to either tell the user how to enter the date which many people are fine with because the Internet is so international::
Birth Date: ______ (mm/dd/yyyy)

Or you need to check some browser variables of the user to estimate the country they are from and revamp your site to match that format. This is a very convoluted method and there's no promise that you will pick the right region or that the user will enter the date guessing at -your- date format.

So I suggest use the above code and just request the user enter one format and you show them the same format back.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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