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.
Printable View
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.
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
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?
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
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
Hi Pres,
Thanks for the replies. This is the requirement:
I have textbox, initialized to the today's Date from server.
The server's regional setting would be always 'MM/dd/yyy'.Code:<input name="txtDate" value="<%=Date()%>"
onclick=ShowDTP(this)>
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?
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.