33

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 ???!!!

Nader El Masry
  • 433
  • 1
  • 6
  • 11

9 Answers9

50
- Open IIS 7
- Select your website
- Open .NET GLOBALIZATION
- From Culture tab, select required Culture and UI Culture.
- Do iisreset
Dmitry Pavlov
  • 30,789
  • 8
  • 97
  • 121
  • follow the blog https://code2night.com/Blog/MyBlog/How-to-set-Date-and-time-format-in-IIS-Manager – Shubham Aug 14 '20 at 19:22
27
  • 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
Nedim
  • 676
  • 1
  • 7
  • 9
  • Great answer, removes the need to set the '.NET Globalization' setting for each individual site. – Francis Dean May 16 '17 at 13:40
  • Awesome thanks. Also allows you to override specific settings, which you can't do via web.config. – Savage Jul 30 '18 at 11:53
  • Thank you very much. I went through my system settings a million times and could not understand why DateTime format was not being respected by IIS. Makes sense now! – clamchoda May 13 '19 at 23:43
  • Just a FYI to this, the copy settings applies to "new" user accounts. If (like me) the user running the app pool was an existing domain user, then you need to log into the server as that account and change the settings for it as well, or the old settings will persist. – guytz72 Jun 24 '21 at 22:22
18

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.

Verena Haunschmid
  • 1,252
  • 15
  • 40
Luis
  • 5,786
  • 8
  • 43
  • 62
  • I changed it via Control panel (from MM/dd to dd/MM format), rebooted the server, but still IIS is showing it wrongly. I checked Regedit, but the changes have also been applied there (most likely when I changed the control panel settings). Is there something special I must do for IIS to notice these changes? Like I said, machine (it's a VM) was rebooted but no effect... – Flater Feb 19 '13 at 10:40
  • @Flater After you restart, the changes are still there? Check the `regional settings` also, maybe the change its not as deep as the Regedit can go, it could be something `"on the surface"`, like just changing it on `control panel` – Luis Feb 19 '13 at 14:06
  • I checked (and changed it) via Regional and Language settings on the Control Panel, I then checked via the clock in the taskbar, and I checked regedit. All three were changed at the same time when I changed the settings via Control Panel. Rebooted the server, even deleted and added the website back in IIS. No change on the website, although the server itself is now in the correct date format... – Flater Feb 20 '13 at 08:54
12

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" />
Marztres
  • 460
  • 8
  • 15
4

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
PRADEEP N
  • 49
  • 9
3

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.

0lukasz0
  • 3,155
  • 1
  • 24
  • 40
2

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

Change System Locale

Kieran
  • 17,572
  • 7
  • 45
  • 53
1
  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
Sailendra
  • 23
  • 5
0

If you have changed you system date format and Clicked on Copy Settings to ALl User accounts and still your new format not getting applied to IIS hosted WebProject.Than you must try to go to APplication Pool Idnetity and Change the User Account and then again try to copy settings to All User accounts. Get reference from here it worked for me How to Set date and time format in IIS

Shubham
  • 443
  • 2
  • 10