How to set Date and time format in IIS 7 - iis-7

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

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

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

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.

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" />

Please try the below steps.Its works for me
Check app pool of your application in IIS.
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.
Restart your app in IIS

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.

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...
Change System Locale
Change Region Settings to desired

Change your system short date and log date format as desired.
Check app pool of your application in IIS.
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)
Restart your app in IIS

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

Related

Asp.Net/ IIS while saving record date coming in Chinese

In my Asp.Net application when I save or update a record the date is coming as #CreatedAt = N'06-May-2015 02:49:03 下午 only the AM/PM part is coming in chinese while in systems Region and language setting Format is English and Location is Macau S.A.R. The Webapplication also supports Chinese language through Globalization.
Make sure the CurrentCulture property is not being set to zh-CHT (or something equivalent) either in your Web.config or the Page where the record is being saved in code.
Go to IIS -> .NET Globalization and check the culture there. Make sure it is Invariant. Check the below screen shot
Check below in IIS setup

Windows Server display settings not showing as it should

On my Windows Server 2008 R2 server, I've set the:
"Region and Language" -> "Formats" -> "Danish (Denmark"
When I see the settings here, and when I click the "Additional Settings", it seems correct. However, in my application, it is not set correct. Here my output is still American.
For instance, these two situations I get the problem:
Datetime.ToString() gives 11/4/2012 1:18:38 PM instead of 04/11/2012 13:18:38 .
When I input a double with 50,00 it is ignored and is set to 5000. When using a dot, it works. it should be a decimal
Of course I could all set this in the application specifically, but I wonder why it is set to English as default when I've set the Formats to Danish.
I've also set the following:
Location = "Denmark"
Default Input Language = "Danish"
How do I fix it? :-)
ASP.NET runs under a different user account, so you'll need to copy the regional settings across.
In the Region and Language control panel, on the Administrative tab, you should have a Copy settings... button. This will copy the settings from your account to the welcome screen, system accounts and new user accounts.
Another thing to check would be the <globalization> section in your web.config file - you might be picking up the culture settings from the user's browser.

What is the best IFormatProvider for Logging?

I have an installable ASP.Net application that is logging using Common.Logging.
When writing log messages ie:
_log.InfoFormat(CultureInfo.???, "{0}: Writing to the Log", DateTime.UtcNow);
I am confused about which culture I should be using. The result I want is that the log messages are formatted using the server's regional settings. That way when administrators install the application they have control over how their log messages are formatted.
There are fours options but none seem to be the correct choice:
CultureInfo.CurrentCulture: this seems like it would be the correct choice for a windows app but ASP.Net is changing this to match the user browsing the site - so it's appropriate for formatting content to display to the user but not for writing to the log.
CultureInfo.CurrentUICulture: similar problems to CurrentCulture - will match the current user browsing the site.
CultureInfo.InstalledUICulture: the system installed culture - appears to relate to the copy of windows installed but not alterable by the user. Apparently this one is a bit useless
CultureInfo.InvariantCulture: this is not user configurable. I am wondering if this is the best of the four options here though because at least it is consistent and won't vary by who is browsing the site/the media windows was installed from.
I am left wondering if I need to add explicit configuration in my web.config for the system culture so the installer can choose a culture. The answer I really want is whatever CultureInfo.CurrentCulture was before ASP.Net changed it to match the current user.
Note: I know I can turn off ASP.Net changing the CurrentCulture per user but the UI relies on this behaviour.
Admins like to have control over the logs. Telling them to go configure their server culture so that the logs are in a particular format doesn't seem like the best solution to me.
Adding a configuration option into web.config is a good idea. This will let the admin configure the log format as required.
Rather than ask the user, you could make an intelligent guess while installing using CultureInfo.CurrentCulture. If the user wants it to be something different, he can always change it.
If you do want to take it from CultureInfo.CurrentCulture rather than configuration, you can pick it during the Application_Start event, and keep it in the application context.

Datetime format issue in IIS 7 server

I have hosted one of my site on IIS 7, WS2008. Later i have realize there is some datetime format issue, like me expecting things in dd/MM/yyyy format but it was in MM/dd/yyyy format and because of this it used to give me datetime conversion error.
So i have changed the datetime format by following step:
Control Panel -> Regional and Language Options -> Advanced
and changed registry entry
regedit >> HKEY_USERS>>DEFAULT>>Control Panel>>International
and here we have changed "sLongDate" and "sShortDate" key in dd MM yyyy format
and restarted the server.
Now, the issue is if i create new website i'll found everything is working fine including my datetime format as well
But my actual site which i have created before making all these datetime setting changes is having no change at all, still i m facing same datetime issue.
So i have deleted that site and hosted same site again with same IP address and at same port, but still same issue.
So, is it like there is some configuration of datetime for specific port.
I can not change my port.
Please suggest me proper solution.
Thanks in Advance...
After lot's of hunt i have found the solution of my problem:
1) Change the datetime format of your server from:
Control Panel -> Regional and Language Options -> Advanced
2) Open IIS and follow below steps: (For IIS7)
- Click on you Website
- Select .NET GLOBALIZATION option
- From Culture tab, select required Culture and UI Culture.
- Finally iisreset.
- Dones....
Change in registry entry
regedit >> HKEY_USERS >> DEFAULT >> Control Panel >> International
and we have changed "sLongDate" and "sShortDate" key in dd MM yyyy format
and restart server.
Change the datetime format of your server from:
Control Panel -> Regional and Language Options -> Advanced
Open IIS and follow below steps: (For IIS7)
Click on you Website
Select .NET GLOBALIZATION option
From Culture tab, select required Culture and UI Culture.
Finally iisreset.
Dones....
This Answer posted by Sham worked for us. We were upgrading the server and there were no changes in application or DB but after upgrade we got string format issue for date time. Above suggestion helped me...

How can we temporary off the running website & gives a message "This site is Temprorary unavailable"

How can we temporary off the running website & gives a message "This site is Temprorary unavailable", actully i want to gives a power to admin he can temporary on/Off the website... according to my need i dnt want to add web_offline.htm page. I simply do it by button control i.e. Active website & Deactive website(dynamic method)
I think the easiest way to do this per your requirements would be to create an app_offline.html, and connect a simple rename method to your admin on/off button. When the admin clicks On, rename the file to app_offline_.html, or whatever, and vice versa. That would be a simple implementation, and you could given the IIS worker process access to that one file for security reasons.

Resources