C#时间控件使用

来源:互联网 发布:龙芯3a3000知乎 编辑:程序博客网 时间:2024/04/30 02:15

简单的做法是转换成指定精度的String,然后比较字符串。Date d1 = datetimepicker.date ;Date now = DateTime.Now ;假设精确到分钟:int result = now.toString ("yyyy-MM-dd hh:mi").compareTo (d1.toString ("yyyy-MM-dd hh:mi")) ;假如result = 0 表示相等。result > 0表示当前时间晚于指定时间,即:已过指定时间。result < 0 表示当前时间早于指定时间,即:未到指定时间。

原创粉丝点击