每隔一秒获取时间
private DispatcherTimer ShowTimer;//系统时间 ShowTimer = new System.Windows.Threading.DispatcherTimer(); ShowTimer.Tick += new EventHandler(ShowCurTimer);//起个Timer一直获取当前时间 ShowTimer.Interval = new TimeSpan(0, 0, 0, 1, 0); ShowTimer.Start(); public void ShowCurTimer(object sender, EventArgs e) { //"星期"+DateTime.Now.DayOfWeek.ToString(("d")) //获得星期几 this.Tt.Text = DateTime.Now.ToString("yyyy年MM月dd日"); this.Tt.Text += " "; //获得年月日 this.Tt.Text += DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("zh-cn")); //yyyy年MM月dd日 this.Tt.Text += " "; //获得时分秒 this.Tt.Text += DateTime.Now.ToString("HH:mm:ss"); //System.Diagnostics.Debug.Print("this.ShowCurrentTime {0}", this.ShowCurrentTime); }