試圖獲取不同國家(時區)的日期然後顯示它。我收到時間和日期。只需要日期如何從不同的時區C獲取日期部分#
var info = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
var dateTime = TimeZoneInfo.ConvertTime(DateTime.Now.Date, info);
MessageBox.Show(dateTime.Date.ToString());
極品2015年5月5日,但還不是時候
您是否需要支持全球化,是應用程序在許多國家還是僅用於一個位置。 –
要將DateTime設置爲字符串格式並獲取不同的格式,請檢查ToString文檔,它接受一個指定格式的參數,或者使用'.ToShortDateString()'。 –
MessageBox.Show(dateTime.Date.ToString(「dd/MM/yyyy」)); –