2013-11-03 16 views
0

我想要使用Application_BeginRequest方法更改所有系統的日期時間格式。 現在我用這個方法使用Application_BeginRequest方法更改日期格式化

protected void Application_BeginRequest(object sender, EventArgs e) 
    { 
     CultureInfo newCulture = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone(); 
     newCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy hh:mm tt"; 

     Thread.CurrentThread.CurrentCulture = newCulture; 

    } 

我認爲它應該顯示日期時間酸鹽這樣的「2013年3月11日上午01時59」,但實際上它是出現這樣的「2013年3月11日01 :59 AM 1:59:03 AM「。那麼,什麼是我的問題解決了這個問題

回答

0

,我使用下面的方法

protected void Application_BeginRequest(object sender, EventArgs e) 
    { 
     CultureInfo newCulture = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone(); 


     newCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy"; 
     newCulture.DateTimeFormat.LongTimePattern = "hh:mm tt"; 

     Thread.CurrentThread.CurrentCulture = newCulture; 

    }