How to set Date and time format in IIS 7

2019-01-11 03:11发布

问题:

I have date format in my local machine : (d/M/yyyy h:mm tt) ==> (23/6/2011 4:30 PM)

when i publish my website on IIS server it converts date format to (M/d/yyyy H:mm)

i changed the date and time formats of the server but it's not affected . i changed the culture of the website to English US time format solved but date not. (M/d/yyyy hh:mm tt) i changed the culture of the website to English UK date format solved but time not. (d/MM/yyyy H:mm)

what is the solution to make it's format like my local format ???!!!

回答1:

- Open IIS 7
- Select your website
- Open .NET GLOBALIZATION
- From Culture tab, select required Culture and UI Culture.
- Do iisreset


回答2:

I was having the same problem, I just found a solution, you need to change the key on the server, follow this steps:

  • Go into Registry Editor (start -> run -> type regedit).
  • Get into the folder HKEY_USERS -> .DEFAULT -> Control Panel -> International.
  • Look for the key sShortDate, right click -> Modify...
  • Change the Value data for d/M/yyyy.
  • Log off. Then next time you log in, dates should be work as you wanted.

That should do the trick, you can also change the sLongDate.



回答3:

  • Go to Control Panel
  • Click Region and you will see a screen with 3 tabs (Formats, Location and Administrative)
  • Click Formats and choose the settings you prefer
  • Click Location and choose the settings you prefer
  • Click Administrative tab. For "Welcome screen and new user accounts", click copy settings. From the new window, click both checkboxes for 'welcome screen and system accounts' and 'new user accounts' (if you skip this step, you will still see the issue because IIS uses system account)
  • Approve all changes for Region by clicking Ok on all open windows
  • Open Command prompt, write iisreset and enter
  • If you still don't see the changes try logoff and logon


回答4:

Try to put this line in the system.web of the web.config, modify the data of culture to your country.

<globalization uiCulture="es-CO" culture="es-CO" enableClientBasedCulture="false" />


回答5:

This is based on Nedim answer, but with tweak:

  • Go to Control Panel
  • Click Region and you will see a screen with 3 tabs (Formats, Location and Administrative)
  • Click Formats and choose the settings you prefer
  • Click Additional settings
  • Click Date tab
  • Change Short date to desired format and confirm dialog
  • Click Location and choose the settings you prefer
  • Click Administrative tab. For "Welcome screen and new user accounts", click copy settings. From the new window, click both checkboxes for 'welcome screen and system accounts' and 'new user accounts' (if you skip this step, you will still see the issue because IIS uses system account)
  • Approve all changes for Region by clicking Ok on all open windows
  • Open Command prompt, write iisreset and enter
  • If you still don't see the changes try logoff and logon

In my case the default format for my country was wrong and I couldn't pick proper format except choosing someting else with desired format. But there was web.config with globalization set to my local culture which had precedense.



回答6:

Please try the below steps.Its works for me

  1. Check app pool of your application in IIS.
  2. Go to Application pool of your website and change Identity of that pool to local service(because your desired date format you have set is in your local system) in Advance setttings.
  3. Restart your app in IIS


回答7:

Even after setting application locale it was still picking up the application pool users locale. I had to change the region settings for all users. This screen shot might help...

  1. Change System Locale
  2. Change Region Settings to desired



回答8:

  1. Change your system short date and log date format as desired.
  2. Check app pool of your application in IIS.
  3. Go to Application pools section of IIS and change Identity of that pool to local system(because your desired date format you have set is in your local system)
  4. Restart your app in IIS


标签: iis-7