利用ASP.NET的CultureInfo來達到民國年時間格式的呈現
最好剛好遇到一個時間格式要顯示民國的案子.....
到網路找了資料...有一個不錯的例子....分享給大家呀.....
C#語法.....
1 protected void Page_Load(object sender, EventArgs e)
2 {
3 //設定台灣日曆
4 System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("zh-TW");
5 ci.DateTimeFormat.Calendar = new System.Globalization.TaiwanCalendar();
6 System.Threading.Thread.CurrentThread.CurrentCulture = ci;
7 //顯示民國年時間
8 Response.Write(DateTime.Now.ToShortDateString());
9 }
2 {
3 //設定台灣日曆
4 System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("zh-TW");
5 ci.DateTimeFormat.Calendar = new System.Globalization.TaiwanCalendar();
6 System.Threading.Thread.CurrentThread.CurrentCulture = ci;
7 //顯示民國年時間
8 Response.Write(DateTime.Now.ToShortDateString());
9 }
結果→96/11/22