1

The server where I publish my Website, the format is M/d/yyyy (eg: 2/25/2016)

But in the website, the date format is d/M/yyyy (eg: 25/2/2016). I want the date format in the website to be M/d/yyyy (like the server format).

Date: <%=now()%>

in .asp page, above code will return current date with d/M/yyyy. I checked a few questions here in stackoverflow but none of them provided a solution for me. I changed the server date format, still no change. I change the culture setting in web.config (see code below) and restarted the IIS service and the server twice. Also the date still in d/M/yyyy format.

<globalization uiCulture="en-US" culture="en-US" enableClientBasedCulture="false" />

Any suggestions?

user692942
  • 16,398
  • 7
  • 76
  • 175
Waller
  • 433
  • 1
  • 6
  • 20

2 Answers2

1

In file GLOBAL.ASA, in Sub Session_OnStart, put Session.LCID = 1033

List of LocaleID could be found at https://msdn.microsoft.com/en-us/goglobal/bb964664.aspx

Date format will be: 8/2/2016 11:16:18 AM

Zam
  • 2,880
  • 1
  • 18
  • 33
0

The functions Date() and Now() in VBScript are controlled but the regional settings defined on the server they are running. Looking at the documentation it's quite clear:

From VBScript Language Reference - Now Function
Returns the current date and time according to the setting of your computer's system date and time.

Also for future reference the globalization config section is directly related to ASP.Net and not Classic ASP. Setting the value of the globalization config section will have no effect on a Classic ASP Web Application.

You however have options for controlling the string representation of a date / time value in VBScript, which is already detailed here - Format current date and time.

Or as @Zam has already suggested you do have some minor control of the format by using the

Session.LCID = 1033

Bear in mind that this will change the entire locale to en-US (which I assume is what you are trying to do with the globalization settings in web.config).

Community
  • 1
  • 1
user692942
  • 16,398
  • 7
  • 76
  • 175