Results 1 to 7 of 7

Thread: reading Regional setting- Urgent

  1. #1

    Thread Starter
    Hyperactive Member jeba's Avatar
    Join Date
    Feb 2000
    Posts
    265

    Exclamation reading Regional setting- Urgent

    Hi there!
    Is there anyway I can read the client's regional setting like 'Short Date format' using Javascript/VBscript?

    Your help is greatly appreciated!
    Thanks in advance.
    J£ßä

  2. #2
    Addicted Member MrPresident2k's Avatar
    Join Date
    May 2002
    Location
    INDIA
    Posts
    167

    Hi

    You can use the date object in JavaScript and frame the date according to that. For example,
    x = new Date()
    x.getDate(), will give u the date and similarly u can use
    x.getDay()
    x.getMonth()
    x.getYear() and so on, and this u can use it for time also.

    Pres

  3. #3

    Thread Starter
    Hyperactive Member jeba's Avatar
    Join Date
    Feb 2000
    Posts
    265

    Thanks.. but

    Hi Pres,
    Suppose a client has 'dd/MM/yyyy' as short date format in the Regional Setting, I want to display the date in 'dd/MM/yyyy' format. Similarly if another client has the 'MM/dd/yyyy' setup in the regional setting, I want to display in 'MM/dd/yyyy' format.

    In order to do that, I need to get the date settings in the 'Regional Setting' of Control Panel. Is there anyway I can read the client's regional setting using Javascript/VBscript?
    J£ßä

  4. #4
    Addicted Member MrPresident2k's Avatar
    Join Date
    May 2002
    Location
    INDIA
    Posts
    167

    try toLocaleDateString()

    Hi,

    The method dateObject.toLocaleDateString() gets the regional settings date in Long form as in regional settings. But I don't think there is a way to obtain short date format. Try with this.

    Thanks,
    Pres

  5. #5
    Addicted Member MrPresident2k's Avatar
    Join Date
    May 2002
    Location
    INDIA
    Posts
    167

    Try this also

    Hi,

    Try with VbScript, byu default VbScript Date takes the short date from the Regional settings. Try this code with changing the local machines short date formats in regional settings. It worked for me.

    msgbox Date()

    Thanks,
    Pres

  6. #6

    Thread Starter
    Hyperactive Member jeba's Avatar
    Join Date
    Feb 2000
    Posts
    265
    Hi Pres,
    Thanks for the replies. This is the requirement:

    I have textbox, initialized to the today's Date from server.

    Code:
    <input name="txtDate" value="<%=Date()%>" 
    onclick=ShowDTP(this)>
    The server's regional setting would be always 'MM/dd/yyy'.
    Assuming that today's date is 'Aug 15 2002', if the client's regional setting is 'dd/MM/yyyy' then I want to display as '15/08/2002', instead of '08/15/2002'.

    Also the user can change the date using a datepicker. Now I want to pass the output format of the date to be displayed to the function (ShowDTP) in order to display the date in the user's regional setting format. You see what I am saying?
    J£ßä

  7. #7
    Addicted Member MrPresident2k's Avatar
    Join Date
    May 2002
    Location
    INDIA
    Posts
    167

    Try this code

    Hi Jeba,

    Try this piece of code, this worked for me.

    <%@ Language=VBScript %>
    <%
    d = Date()
    %>

    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

    <Script Language="VbScript">
    sub sample
    d = "<%=d%>"
    msgbox d
    s = split(d,"/")
    document.a.s.value = DateSerial (s(2),s(0),s(1) )
    End sub
    </Script>

    </HEAD>
    <BODY OnLoad="sample">
    <form name=a>
    <input name=s>
    </form>
    </BODY>
    </HTML>

    And only thing u have to check is whether ur date is seperated by "/" or "-".

    Pres.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width