|
-
Aug 14th, 2002, 02:37 AM
#1
Thread Starter
Hyperactive Member
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.
-
Aug 14th, 2002, 03:31 AM
#2
Addicted Member
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
-
Aug 14th, 2002, 04:10 AM
#3
Thread Starter
Hyperactive Member
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?
-
Aug 14th, 2002, 06:47 AM
#4
Addicted Member
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
-
Aug 14th, 2002, 07:00 AM
#5
Addicted Member
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
-
Aug 14th, 2002, 07:23 AM
#6
Thread Starter
Hyperactive Member
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?
-
Aug 14th, 2002, 08:26 AM
#7
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|