C# 简单时间操作

来源:互联网 发布:淘宝店心得 编辑:程序博客网 时间:2024/05/09 23:24

public string now = String.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now);

 

DateTime deadLine = new System.DateTime(2012, 01, 01);
if (deadLine.CompareTo(System.DateTime.Today) > 0)
{
 MessageBox.Show("世界末日快来了,深挖洞,广积粮...");
}
if (deadLine.CompareTo(System.DateTime.Today) = 0)
{
 MessageBox.Show("世界末日到了,快躲起来...");
}
 if (deadLine.CompareTo(System.DateTime.Today) < 0)
{
 MessageBox.Show("世界末日过去了,我依然坚挺...");
}

0 0