private void buttonSure_Click(object sender, EventArgs e) { // MessageBox.Show(this.userControlChoiceTime1.GetUserChoiceTime().ToLocalTime().ToString()); DateTime userChoiceTime = this.userControlChoiceTime1.GetUserChoiceTime(); //TimeSpan ts1 = new TimeSpan(userChoiceTime.Ticks); //TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks); //TimeSpan ts = ts1.Subtract(ts2).Duration(); if (ConvertDateTimeInt(userChoiceTime) - ConvertDateTimeInt(DateTime.Now)<0) { MessageBox.Show("O(∩_∩)O貌似不能回到过去发邮件!"); } } // DateTime时间格式转换为Unix时间戳格式 public int ConvertDateTimeInt(System.DateTime time) { System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); return (int)(time - startTime).TotalSeconds; }