views:

77

answers:

2

In asp.net I'm using this one:

System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern

Is that possible to get it in classic asp?

A: 

Use this VB Script Function

Response.write(formatDateTime(Now(), vbShortDate))

EDIT:

Better try from client side check this link

http://www.merlyn.demon.co.uk/js-other.htm#Deloc

solairaja
no, it bring me a date, what what I need, that function will return string (DatePattern) like: mm/dd/yyyy for en-US and dd/mm/yyyy for en-CA
msony
YOU HAVE TO USE GetLocale() TO IDENTIFY THE LOCATION AND THEN YOU HAVE TO FORMAT THE DATE ACCORDINGLY. THERE IS NO GO OTHER THAN THIS.
solairaja
check the edits
solairaja
but I what that culture will stay at server side
msony
still you can use the culture information using clientscripts
solairaja
ok, i will try it, but first reading
msony
A: 

It's a while since I used VBScript but I think that combining FormatDateTime with the correct locale should give you a localised date. You can use SetLocale() to change the locale the script is using, that might be particularly necessary if you want to use the client locale rather than the server one. The actual options formatDateTime offers are pretty limited though - more or less vbShortDate or vbLongDate.

If you need more flexibility you will either need to roll your own or perhaps to use a standard format to pass the date to the client and then format it there using JavaScript which may open up a few options for you.

glenatron