Search code examples
iisvbscriptasp-classic

Server date and IIS date format different


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?


Solution

  • 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