Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
ASP.NET 2.0 / 3.5 / 4.0
C# TimeSeparator, differenze legate al server
giovedì 31 gennaio 2013 - 11.29
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
Elenco Tags
C#
|
.NET 3.5
volperubbia
Profilo
| Senior Member
375
messaggi | Data Invio:
gio 31 gen 2013 - 11:29
Ciao a tutti,
pubblicando la mia applicazione web ASP.NET MVC 3.5 su due server differenti, ho notato differenze di visualizzazione della data ora, quando l'italiano è la lingua corrente. Probabilmente si prende le impostazioni internazionali dal server.
Esempi:
<%= DateTime.Now.ToString() %>
<%= DateTime.Now.ToString(System.Threading.Thread.CurrentThread.CurrentCulture) %>
<%= String.Format("{0:G}", DateTime.Now) %>
Su un server mi mette i ":" come TimeSeparator, sull'altro il ".".
Ho provato nell'Application_AuthenticateRequest con:
if (System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName == "it") {
System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.TimeSeparator = ":";
System.Threading.Thread.CurrentThread.CurrentCultureUI.DateTimeFormat.TimeSeparator = ":";
};
ma non ottengo cambiamenti.
Qualche idea su come uniformare il comportamento indipendentemente dal server che ospita l'applicazione?
Grazie per l'attenzione,
Davide
andrestu
Profilo
| Expert
772
messaggi | Data Invio:
dom 3 feb 2013 - 11:52
prova a inserire questo nel web.config
<system.web>
....
<globalization culture="it-IT" uiCulture="it-IT"/>
....
</system.web>
Andrea Restucci - Web Developer
volperubbia
Profilo
| Senior Member
375
messaggi | Data Invio:
lun 4 feb 2013 - 12:14
Ciao Andrea,
no serve ... ho ricontrollato e basta impostare su Application_AuthenticateRequest:
if (System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName == "it") {
System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.LongTimePattern = System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.LongTimePattern = "HH:mm:ss";
System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortTimePattern = System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.ShortTimePattern = "HH:mm";
System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.TimeSeparator = System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.TimeSeparator = ":";
};
Grazie comunque,
Davide
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !